tensorflow / tensorflow/models
Got an AttributeError: module 'tensorflow' has no attribute 'contrib' when following Tensorflow 2.0 object detection tutorial
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
Please answer the following questions for yourself before submitting an issue.
- [X ] I am using the latest TensorFlow Model Garden release and TensorFlow 2.
- I am reporting the issue to the correct repository. (Model Garden official or research directory)
- I checked to make sure that this issue has not been filed already.
1. The entire URL of the file you are using
2. Describe the bug
I am using tensorflow 2.0 and tried to follow the object detection tutorial (https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/auto_examples/object_detection_camera.html). However, when I tried to load the model, I got an Attribute error.
I did the research online and got the answer that you have to use tensorflow 1.4 to make the object detection work. and contrib has been deprecated in tensorflow 2.0.
I am confused that the tutorial for tensorflow 2.0 object detection api will require tensorflow 1.x??
3. Steps to reproduce
Use tensorflow 2.0, follow the TF 2.0 object detection tutorial, and when you load the model, you will get the issue.
4. Expected behavior
model get loaded correctly.
5. Additional context
Include any logs that would be helpful to diagnose the problem.
AttributeError Traceback (most recent call last)
in
8 from object_detection.utils import config_util
9 from object_detection.utils import visualization_utils as viz_utils
---> 10 from object_detection.builders import model_builder
11
12 tf.get_logger().setLevel('ERROR') # Suppress TensorFlow logging (2)
~\Anaconda3\envs\tf20\lib\site-packages\object_detection\builders\model_builder.py in
20 from object_detection.builders import anchor_generator_builder
21 from object_detection.builders import box_coder_builder
---> 22 from object_detection.builders import box_predictor_builder
23 from object_detection.builders import hyperparams_builder
24 from object_detection.builders import image_resizer_builder
~\Anaconda3\envs\tf20\lib\site-packages\object_detection\builders\box_predictor_builder.py in
18 import collections
19 import tensorflow as tf
---> 20 from object_detection.predictors import convolutional_box_predictor
21 from object_detection.predictors import convolutional_keras_box_predictor
22 from object_detection.predictors import mask_rcnn_box_predictor
~\Anaconda3\envs\tf20\lib\site-packages\object_detection\predictors\convolutional_box_predictor.py in
20 from object_detection.utils import static_shape
21
---> 22 slim = tf.contrib.slim
23
24 BOX_ENCODINGS = box_predictor.BOX_ENCODINGS
AttributeError: module 'tensorflow' has no attribute 'contrib'
6. System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): windows 10
- Mobile device name if the issue happens on a mobile device:
- TensorFlow installed from (source or binary): anaconda
- TensorFlow version (use command below): 2.0
- Python version: 3.7
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version:
- GPU model and memory:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.