tensorflow / models

Models and examples built with TensorFlow
Other
77.18k stars 45.76k forks source link

ObjectDetection API not suitable for tf 2.0.0-alpha0 #6423

Closed theangels closed 3 years ago

theangels commented 5 years ago

System information

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

snipaste20190322_205738

@wangtz

rootkitchao commented 5 years ago

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.

JoseLuisFriedrich commented 5 years ago

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?

rootkitchao commented 5 years ago

I don't know the specific situation.But the object detection API will be updated to Tensorflow 2.0.

theangels commented 5 years ago

I don't know the specific situation.But the object detection API will be updated to Tensorflow 2.0.

Oh yeah! Thanks a lot.

austinmw commented 5 years ago

@rootkitchao Any idea what the timeline for that is? Just curious, I know it will likely require a lot of work.

omerrciftcii commented 5 years ago

@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

pkulzc commented 5 years ago

We are collaborating with TF team to migrate to 2.0 now, but this is a huge effort which may take months.

Borda commented 5 years ago

Any update on the actual status of migration to TF 2.0? Are there some particular actions/points that the community may be helpful?

yanfengliu commented 5 years ago

@omerrciftcii I think your best option right now is to just create a virtual env with tensorflow 1.x

lucasjinreal commented 5 years ago

@pkulzc How's the progress going?

pkulzc commented 5 years ago

We've made some progress but are still not ready for full migration or release.

andreiionutdamian commented 5 years ago

@pkulzc thank you for the update! Maybe some kind of work-around in the mean time?

enyangxxx commented 5 years ago

while having tf 2.0.0: how to handle "module 'tensorflow' has no attribute 'GraphDef' "?

JoeSL commented 5 years ago

@pkulzc any updates on the migration status?

wAikAp commented 5 years ago

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?

johannesjung commented 5 years ago

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.

jpacifico commented 4 years ago

hi, how's the progress going? Is it now possible to use Object Detection API with TF 2.0 ?

Borda commented 4 years ago

@jpacifico I guess it is already released... https://github.com/tensorflow/models/releases/tag/v2.0

swarupe commented 4 years ago

Object Detection API is not yet released with TF 2.0 I guess

jpacifico commented 4 years ago

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

wAikAp commented 4 years ago

As anyone knows any other ways to train the model with TF2.0 for now situation?

vikramg1 commented 4 years ago

I tried it and it has the same contrib error. Did anyone get it up and running successfully?

KaneFury commented 4 years ago

Hey guys.. does anyone know if the object detection API was updated for TF2 and is working fine?

SaschaHeyer commented 4 years ago

Hey @pkulzc

I see this issues is closed, is the Object Detection API already updated for TF2? Also wondering why this issues is closed, a ETA or update would be great.

Borda commented 4 years ago

Maybe create a milestone add there issues and PRs which gas to be done before TF2 compatible...

sanchit88 commented 4 years ago

Is there any update? TF2.0 is still not working and getting the same "AttributeError: tf.contrib" error.

vihari1729 commented 4 years ago

while having tf 2.0.0: how to handle "module 'tensorflow' has no attribute 'GraphDef' "?

@enyangxxx Currently tf 2.0.0 doesn't support graphdef model. You should either use keras model or saved model

Masoud-Ghodrati commented 4 years ago

is there any update on this issue? It's frustrating. The way I solved my problem was to use google colab, but training a model for long hours using on colab is a pain.

Please give us some update

vihari1729 commented 4 years ago

is there any update on this issue? It's frustrating. The way I solved my problem was to use google colab, but training a model for long hours using on colab is a pain.

Please give us some update

@Masoud-Ghodrati Downgrade your tensorflow version to TF 1.x and try running the code. It may work

sanchit88 commented 4 years ago

@all: I have tried a combination of Tensorflow 1.15 and Tensorflow models v1.13.0. And, both are working fine. Note that it is important you need to checkout v1.13.0 tag when you download models repo!

At the moment, Tensorflow model v2.0 is still not working.

manfye commented 4 years ago

yes still not working, frust

ljstrnadiii commented 4 years ago

Looks like there has been some progress:

https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb

dheera commented 4 years ago

It would be actually really awesome to have an object detection API that is completely abstracted from the framework, such that you could use TF 1.x, TF 2.x, or even PyTorch or other framework to supply a model to use. The API shouldn't need to know that it's TensorFlow or some specific version under the hood; the model should be supplied with the relevant bindings to the specific framework and version that the model depends on.

It should in principle take only a simple line change of e.g. from object_detection import ObjectDetector model = ObjectDetector("/path/to/some_model_A_that_uses_tensorflow_1_13.model") to model = ObjectDetector("/path/to/some_model_B_that_uses_tensorflow_2_0.model") or model = ObjectDetector("/path/to/some_model_C_that_uses_pytorch.model") to switch from one model to another. The .model file should be a tarball that is fully self-contained, including:

All this should be self-contained in that one file. This would make it as easy to share machine learning models as it is to share Android apps that are assembled into a single .apk file.

After this one line of code, all it should take to get inferences should be: detections = model.detect([some_opencv_image, some_pil_image, "/path/to/some.jpg"]) and it should be able to deal with all of these common image types and run a batch inference.

Thoughts? I'd be willing to help build part of this if it's of interest and hasn't been done.

vikramg1 commented 4 years ago

@dheera , we are building something close to what you stated above for Edge IoT computer vision: https://alwaysai.co/

Masoud-Ghodrati commented 4 years ago

Looks tike there has been some progress:

https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb

how? it works on colab but not locally? have you tried it locally?

ljstrnadiii commented 4 years ago

@Masoud-Ghodrati , well, as you can see, it is 2.x with the object_detection api installed. It was also pushed a few days ago.

Nightly docker build is not working with it for me.

Masoud-Ghodrati commented 4 years ago

@Masoud-Ghodrati , well, as you can see, it is 2.x with the object_detection api installed. It was also pushed a few days ago.

Nightly docker build is not working with it for me.

Well, I installed the API on 16 Jan and didn't work on my local machine, the tutorial was TF 2.x. So, I can't see anything new.

Shoshin23 commented 4 years ago

I think the safest option will be to download to tensorflow 1.0. There's still no update for this. :/

sreeni5493 commented 4 years ago

Any updates?

pkulzc commented 4 years ago

Migrating to TF2 includes a number of critical issues:

Finally we have built a few TF2 models and are developing a few more latest models. The release will happen soon. Sorry for the long waiting!

atyshka commented 4 years ago

What about fixing all the imports? On current master in 1.15 there are an abundance of warnings about deprecated names that really clog up the terminal and distract from valuable information. Will the Tensorflow 2.0 automatic converter be able to aid with this?

Borda commented 4 years ago

FYI, detected that version 2.2.0rc2 of tensorflow was released on PyPI at March 27, 2020

haimat commented 4 years ago

Hey guys, I am a bit confused ... This issue here on GitHub is closed, but I can't find any notes on an official release of the Object Detection API for TF2. What is the current status, can we use it with TF2 now? Thanks in advance.

atyshka commented 4 years ago

@haimat No, scroll up you'll notice they closed it even though there is still no TF2 support.

haimat commented 4 years ago

That's why I am a bit confused. We use TF2 in our company, I can't change this. I was looking for something powerful as detector2 for PyTorch, which could be used on top of TF (but not TF1.x). Are there any plans for a release of this Object Detection API for TF2?

atyshka commented 4 years ago

It’s definitely in progress but there’s a lot to do. I haven’t done it myself but your best bet is looking into the backwards compatibility stuff. It is my understanding that you can use tf 1 code in tf 2 using backwards compatible imports. There’s even an automatic conversion tool that will change your code to work with tf 2. I can’t say it’s easy since this repo is large, but that’s probably the simplest way to get things somewhat working in tf 2. It’s definitely better to rewrite things in the tf 2 style, but this might work as a short term fix. Let us know if you get things working!

haimat commented 4 years ago

Hmm... That's unfortunate. The detectron2 framework from Facebook looks really promising, I was hoping to find something similar for TF2. But if there is no such thing (yet), we might be tempted to switch to detectron2 and PyTorch.

vinayentc commented 4 years ago

Hi, any update for the tensorflow 2.0 object detection ? thanks

wAikAp commented 4 years ago

So, need how long we can use the TF2.0 object detection what do you guys think?

alexdwu13 commented 4 years ago

@pkulzc Thanks for keeping us updated. Is there an experimental Obj Det branch we can pull from before an official update is released?