Imageai: module 'tensorflow' has no attribute 'to_float'

Created on 4 Jan 2020  路  6Comments  路  Source: OlafenwaMoses/ImageAI

Hi Olafenwa,

Thank you for developing this package, I am really looking forward to using it! I tried running one of your example scripts, custom_detection_train.py, but I am having some trouble. It seems there are some functions in TensorFlow that are being used that are now depreciated. For instance, when I run the last line of the custom_detection_train.py dataset, trainer.trainModel(), I get the error message:

       AttributeError: module 'tensorflow' has no attribute 'to_float'

I found a hack solution online, which was to insert the code "tf.to_float = lambda x: tf.cast(x, tf.float32)" immediately above this line. However, I get a similar error message for a different function:

       AttributeError: module 'tensorflow' has no attribute 'assign_add'

I am using version 2.0.0 of TensorFlow and version 2.3.1 of keras. If you have any suggestions or comments on what I could do, I would really appreciate it as I would really like to use your package!

Regards,
Nick.

Most helpful comment

I am running into this also. It looks like the information on the front screen is wrong and not up to date, this is what I am referring to in the dependency section:

Python 3.5.1 (and later versions)
Tensorflow 1.4.0 (and later versions) (Tensorflow 2.0 coming soon)
OpenCV
Keras 2.x

Those will not work all the time and especially the newest versions of each do not work together. Can we please get the last known working versions of each of those dependencies(exact)?

Currently I found these to work together:
pip install opencv-python==4.1.2.30
pip install keras==2.3.1
pip install tensorflow==1.14.0
pip install tensorflow-gpu==1.14.0
pip install imageai --upgrade
NOTE: using imageai == 2.1.5

There is no information out there on what version works with what right now and it is stunting the use of this amazing tool.

Cheers!

All 6 comments

I am running into this also. It looks like the information on the front screen is wrong and not up to date, this is what I am referring to in the dependency section:

Python 3.5.1 (and later versions)
Tensorflow 1.4.0 (and later versions) (Tensorflow 2.0 coming soon)
OpenCV
Keras 2.x

Those will not work all the time and especially the newest versions of each do not work together. Can we please get the last known working versions of each of those dependencies(exact)?

Currently I found these to work together:
pip install opencv-python==4.1.2.30
pip install keras==2.3.1
pip install tensorflow==1.14.0
pip install tensorflow-gpu==1.14.0
pip install imageai --upgrade
NOTE: using imageai == 2.1.5

There is no information out there on what version works with what right now and it is stunting the use of this amazing tool.

Cheers!

Hi Olafenwa,

Thank you for developing this package, I am really looking forward to using it! I tried running one of your example scripts, custom_detection_train.py, but I am having some trouble. It seems there are some functions in TensorFlow that are being used that are now depreciated. For instance, when I run the last line of the custom_detection_train.py dataset, trainer.trainModel(), I get the error message:

       AttributeError: module 'tensorflow' has no attribute 'to_float'

I found a hack solution online, which was to insert the code "tf.to_float = lambda x: tf.cast(x, tf.float32)" immediately above this line. However, I get a similar error message for a different function:

       AttributeError: module 'tensorflow' has no attribute 'assign_add'

I am using version 2.0.0 of TensorFlow and version 2.3.1 of keras. If you have any suggestions or comments on what I could do, I would really appreciate it as I would really like to use your package!

Regards,
Nick.

Even i am stuck at the same place after spending hours arranging and getting things in order! :/

Tensorflow 2.0 is not supported for sure. Try to downgrade your TF version to 1.X

Yeah worked on 1.14 for me! Struggling with AWS now for training this upon cloud

should close this issue then... unfortunately I don't have permissions to.

I hope next releases will contain a proper requirements.txt with fixed versions and support for tensorflow 2.

thanks for your time

I have also run into this issue and can confirm that running these versions works:

Currently I found these to work together: pip install opencv-python==4.1.2.30 pip install keras==2.3.1 pip install tensorflow==1.14.0 pip install tensorflow-gpu==1.14.0 pip install imageai --upgrade NOTE: using imageai == 2.1.5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

c7jie picture c7jie  路  4Comments

mbaguant picture mbaguant  路  6Comments

jakubstech picture jakubstech  路  6Comments

palacinka picture palacinka  路  3Comments

flozi00 picture flozi00  路  4Comments