Open grewe opened 4 years ago
Do you happen to know which line is trying to reference tf.contrib?
below is complete error trace that is output in jupyter notebook
AttributeError Traceback (most recent call last)
Have you made sure that the slim folder is on your python path? e,g,
export PYTHONPATH=$PYTHONPATH:/home/ubuntu/models/:/home/ubuntu/models/research/:/home/ubuntu/models/research/slim/://home/ubuntu/lugs/models/research/object_detection/
Have you solved it? I have the same problem. I hope to get your help. @greweI
Hi, I have the exact same problem. Anyone managed to solve this?
I had the same issue when using an anaconda environment 3.7.4 also with the pip distribution of tf_object_detection. I was able to get the object-detection API to work by fixing the dependencies, which for me meant scrapping the conda env and remaking it via this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html
Same issue here. Is "use TF 1.x" the only solution at the moment?? Thx
Full trace:
AttributeError Traceback (most recent call last) Cell In[1], line 47 45 import numpy as np 46 from object_detection.utils import config_util ---> 47 from object_detection.builders import model_builder 48 from object_detection.utils import label_map_util 49 from object_detection.utils import visualization_utils as viz_utils
File ~/miniconda3/envs/jup/lib/python3.12/site-packages/object_detection/builders/model_builder.py:22 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
File ~/miniconda3/envs/jup/lib/python3.12/site-packages/object_detection/builders/box_predictor_builder.py:20 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
File ~/miniconda3/envs/jup/lib/python3.12/site-packages/object_detection/predictors/convolutional_box_predictor.py:22 19 from object_detection.core import box_predictor 20 from object_detection.utils import static_shape ---> 22 slim = tf.contrib.slim 24 BOX_ENCODINGS = box_predictor.BOX_ENCODINGS 25 CLASS_PREDICTIONS_WITH_BACKGROUND = ( 26 box_predictor.CLASS_PREDICTIONS_WITH_BACKGROUND)
AttributeError: module 'tensorflow' has no attribute 'contrib'
Prerequisites
Please answer the following questions for yourself before submitting an issue.
1. The entire URL of the file you are using
https://github.com/tensorflow/models/tree/master/research/...
2. Describe the bug
When trying to import model_builder using following line in my jupyter notebook:
from object_detection.builders import model_builder
get the following error
TF2 AtributeError: module 'tensorflow' has no attribute 'contrib'
Have searched and past discussion is this is error is due to Object Detection being attempted to run with TF2 instead of TF1 but, 10 days ago Object Detection API released in TF2.
3. Steps to reproduce
Steps to reproduce the behavior. Have Jupyter notebook, running tensorflow 2.3 have line of code specified above to import model_builder and fails as discussed
4. Expected behavior
Expect no error.
5. Additional context
Include any logs that would be helpful to diagnose the problem.
6. System information