ObjectDetection API not suitable for tf 2.0.0-alpha0
System information
- What is the top-level directory of the model you are using: /Appendix/tensorflow_models/research
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Nope
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
- TensorFlow installed from (source or binary): binary
- TensorFlow version (use command below): 2.0.0-alpha0, and the models lib clone on Mar 11, 2019
- Bazel version (if compiling from source):
- CUDA/cuDNN version: 10.0
- GPU model and memory: 1050Ti
- Exact command to reproduce:
PIPELINE_CONFIG_PATH='/home/jovyan/Codelab/model/pipeline.config'
MODEL_DIR='/home/jovyan/Codelab/data'
NUM_TRAIN_STEPS=50000
SAMPLE_1_OF_N_EVAL_EXAMPLES=1
python3 object_detection/model_main.py
--pipeline_config_path=${PIPELINE_CONFIG_PATH}
--model_dir=${MODEL_DIR}
--num_train_steps=${NUM_TRAIN_STEPS}
--sample_1_of_n_eval_examples=$SAMPLE_1_OF_N_EVAL_EXAMPLES
--alsologtostderr
tf_upgrade_v2 --intree . --outtree . --copyotherfiles False
Describe the problem
I try to use ObjectDetection API in TensorFlow 2.0.0-alpha0, but the program told me that AttributeError: module 'tensorflow' has no attribute 'contrib', clearly Google has delete the contrlib library. So next step I try to use the tf_upgrade_v2 utility to help me converting existing TensorFlow 1.x Python scripts to TensorFlow 2.0. But finally I failed. Here are the message from terminal.
Source code / logs

@wangtz
The current version of the object detection API requires Tensorflow 1.X (>1.12).Because the current version requires contrib.slim, which was removed in Tensorflow 2.0.
The current version of the object detection API requires Tensorflow 1.X (>1.12).Because the current version requires contrib.slim, which was removed in Tensorflow 2.0.
Is there any date or plan in the future to migrate it to 2.0?
I don't know the specific situation.But the object detection API will be updated to Tensorflow 2.0.
I don't know the specific situation.But the object detection API will be updated to Tensorflow 2.0.
Oh yeah! Thanks a lot.
@rootkitchao Any idea what the timeline for that is? Just curious, I know it will likely require a lot of work.
@rootkitchao Any idea what the timeline for that is? Just curious, I know it will likely require a lot of work.
did you find something? I cant use train.py, it still giving this error: "AttributeError: module 'tensorflow' has no attribute 'contrib' "
I tried to use model_main.py but nothing changes. I don't know what should I do
We are collaborating with TF team to migrate to 2.0 now, but this is a huge effort which may take months.
Any update on the actual status of migration to TF 2.0? Are there some particular actions/points that the community may be helpful?
@omerrciftcii I think your best option right now is to just create a virtual env with tensorflow 1.x
@pkulzc How's the progress going?
We've made some progress but are still not ready for full migration or release.
@pkulzc thank you for the update! Maybe some kind of work-around in the mean time?
while having tf 2.0.0: how to handle "module 'tensorflow' has no attribute 'GraphDef' "?
@pkulzc any updates on the migration status?
I used model_main.py in TF2.0 with the same problem.
Traceback (most recent call last):
File "model_main.py", line 26, in
I tried to use the tf_upgrade_v2 cmd to the eval_util.py and model_main.py its doesn't work. Although I know this behavior is not scientific. BTW, any update for object detection in TF2.0?
I used model_main.py in TF2.0 with the same problem. Traceback (most recent call last): File "model_main.py", line 26, in from object_detection import model_lib File "../object_detection/model_lib.py", line 27, in from object_detection import eval_util File "../object_detection/eval_util.py", line 40, in slim = tf.contrib.slim AttributeError: module 'tensorflow' has no attribute 'contrib'
I tried to use the tf_upgrade_v2 cmd to the eval_util.py and model_main.py its doesn't work. Although I know this behavior is not scientific. BTW, any update for object detection in TF2.0?
Until the Object Detection API is updated to TensorFlow 2 simply use TensorFlow 1.15 (pip install tensorflow==1.15). It still contains contrib and also a complete implementation of the 2.0 API. Using the compat.v2 module you can already ensure that your code (except for the Object Detection API part of course) will work with 2.0. Check the TensorFlow 1.15 release notes for further information.
hi, how's the progress going? Is it now possible to use Object Detection API with TF 2.0 ?
@jpacifico I guess it is already released... https://github.com/tensorflow/models/releases/tag/v2.0
Object Detection API is not yet released with TF 2.0 I guess
Object Detection API is not yet released with TF 2.0 I guess
yes I guess too, still have the same 'contrib' error with TF 2