Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'tensorflow.compat.v2' has no attribute '_internal' #1538

Closed
mahesaAtma opened this issue Jun 2, 2021 · 18 comments
Closed

module 'tensorflow.compat.v2' has no attribute '_internal' #1538

mahesaAtma opened this issue Jun 2, 2021 · 18 comments

Comments

@mahesaAtma
Copy link

mahesaAtma commented Jun 2, 2021

Hi all, really quick question, i get these following error :

2021-06-02 03:36:48.320113: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
Using TensorFlow backend.
Traceback (most recent call last):
  File "keras-retinanet/keras_retinanet/bin/train.py", line 553, in <module>
    main()
  File "keras-retinanet/keras_retinanet/bin/train.py", line 469, in main
    backbone = models.backbone(args.backbone)
  File "keras-retinanet/keras_retinanet/bin/../../keras_retinanet/models/__init__.py", line 57, in backbone
    from .resnet import ResNetBackbone as b
  File "keras-retinanet/keras_retinanet/bin/../../keras_retinanet/models/resnet.py", line 18, in <module>
    import keras_resnet
  File "/usr/local/lib/python3.7/dist-packages/keras_resnet/__init__.py", line 1, in <module>
    from . import layers
  File "/usr/local/lib/python3.7/dist-packages/keras_resnet/layers/__init__.py", line 1, in <module>
    from ._batch_normalization import BatchNormalization
  File "/usr/local/lib/python3.7/dist-packages/keras_resnet/layers/_batch_normalization.py", line 1, in <module>
    import keras
  File "/usr/local/lib/python3.7/dist-packages/keras/__init__.py", line 12, in <module>
    from . import initializers
  File "/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py", line 124, in <module>
    populate_deserializable_objects()
  File "/usr/local/lib/python3.7/dist-packages/keras/initializers/__init__.py", line 49, in populate_deserializable_objects
    LOCAL.GENERATED_WITH_V2 = tf.__internal__.tf2.enabled()
AttributeError: module 'tensorflow.compat.v2' has no attribute '__internal__'

Bassically all i do just installing all package required and execute cython, also i do Keras 2.4 and Tensorflow 2.3.0 as what the repository described. And after installing all packages, i tried to do the training as follow :

!keras-retinanet/keras_retinanet/bin/train.py --freeze-backbone --random-transform\
  --backbone resnet152 \
  --batch-size 8 \
  --steps 610 \
  --snapshot-path gdrive/MyDrive/Tugas_Akhir/snaphots \
  --tensorboard-dir gdrive/MyDrive/Tugas_Akhir/snaphots \
  csv gdrive/MyDrive/Tugas_Akhir/annotation.csv gdrive/MyDrive/Tugas_Akhir/classes.csv \
  --val-annotations gdrive/MyDrive/Tugas_Akhir/annotation_testing.csv

anyone know with this? i really need your help guys, please.

Thanks in advance.

@mahesaAtma
Copy link
Author

mahesaAtma commented Jun 2, 2021

For addition details, i ran it on google collab, about 2 weeks ago, i ran it, and it just working fine, but unfortunately, when i re-run this code,it givesme those errors

@syln21
Copy link

syln21 commented Jun 2, 2021

I guess it's because google colab upgrade tensorflow 2.5 , you should check issue #1537

@mahesaAtma
Copy link
Author

I guess it's because google colab upgrade tensorflow 2.5 , you should check issue #1537

I did install follow versions : 2.1.0 2.2.0 2.3.0 2.3.1 2.3.2 2.4.0 and it gave me error log from the tensorflow itself. And yes, as in the requirements.txt, it will install newest tensorflow, which is currently 2.5.0

But unfortunately, i think keras retinanet is not supported yet for tensorflow 2.5.0? i did the training with 2.5.0, but it gives me 0 mAP with this error message

WARNING:tensorflow:
The following Variables were used a Lambda layer's call (tf.compat.v1.nn.fused_batch_norm_116), but
are not present in its tracked objects:
  <tf.Variable 'bn4b26_branch2b/gamma:0' shape=(256,) dtype=float32>
  <tf.Variable 'bn4b26_branch2b/beta:0' shape=(256,) dtype=float32>
It is possible that this is intended behavior, but it is more likely
an omission. This is a strong indication that this layer should be
formulated as a subclassed Layer rather than a Lambda layer.

@kirthan0899
Copy link

Figured it out.
You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y
!pip uninstall keras-nightly -y
!pip uninstall keras-Preprocessing -y
!pip uninstall keras-vis -y
!pip uninstall tensorflow -y

!pip install tensorflow==2.3.0
!pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

@mahesaAtma
Copy link
Author

@kirthan0899 mannnn you just saved my life, tried dozens of options out there, reinstall, change python version, install anaconda, and other stuff. really want to know, how did you get those answer??

once again, thanksss! love you to the moon! haha

@kirthan0899
Copy link

tried dozens of options out there, reinstall, change python version, install anaconda, and other stuff.

Even I tried all those options and got fed up lol.
And later i went through some open issues and found this.

They had told to uninstall all packages and reinstall required packages, instead I just tried removing keras and tensorflow and it worked.

Anyway glad I could help you out :)

@S16201512
Copy link

Figured it out.
You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y
!pip uninstall keras-nightly -y
!pip uninstall keras-Preprocessing -y
!pip uninstall keras-vis -y
!pip uninstall tensorflow -y

!pip install tensorflow==2.3.0
!pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

I love you,gay.
So good solution!
Thank you

@MEPOO13
Copy link

MEPOO13 commented Aug 13, 2021

Figured it out.
You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y
!pip uninstall keras-nightly -y
!pip uninstall keras-Preprocessing -y
!pip uninstall keras-vis -y
!pip uninstall tensorflow -y

!pip install tensorflow==2.3.0
!pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

Thanks Dear

@mantavya
Copy link

Figured it out.
You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y
!pip uninstall keras-nightly -y
!pip uninstall keras-Preprocessing -y
!pip uninstall keras-vis -y
!pip uninstall tensorflow -y

!pip install tensorflow==2.3.0
!pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

it worked for me thanks!

@tulbureandreit
Copy link

Figured it out.
You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y
!pip uninstall keras-nightly -y
!pip uninstall keras-Preprocessing -y
!pip uninstall keras-vis -y
!pip uninstall tensorflow -y

!pip install tensorflow==2.3.0
!pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

SAVED MY A**. thank you

@ZixianReid
Copy link

Works for me. Thanks!

@hoangnkust
Copy link

hoangnkust commented Dec 30, 2021

Figured it out. You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y !pip uninstall keras-nightly -y !pip uninstall keras-Preprocessing -y !pip uninstall keras-vis -y !pip uninstall tensorflow -y

!pip install tensorflow==2.3.0 !pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

Do you know ???, you just saved my life !!!. Respect Sir !!!

@Abdodt
Copy link

Abdodt commented Mar 15, 2022

importing it as tensorflow.keras.layers ....... will also work
just include " tensorflow. " when importing.

@Anvi98
Copy link

Anvi98 commented Apr 8, 2022

Best answer !

@amzker
Copy link

amzker commented Feb 3, 2023

🤣

@NhatTamNL
Copy link

Figured it out. You just need to uninstall all keras and tensorflow packages and install the versions supported by Retinanet.

!pip uninstall keras -y !pip uninstall keras-nightly -y !pip uninstall keras-Preprocessing -y !pip uninstall keras-vis -y !pip uninstall tensorflow -y

!pip install tensorflow==2.3.0 !pip install keras==2.4

Just add this to the top of your colab notebook and restart your runtime once its completed and then you are good to go.

Hope this helps.

Thanks Dear

@hamedaligha
Copy link

I upgraded tensorflow-probability to version 0.24.0 then installed tf-keras package ---> problem is solved!

@RubTalha
Copy link

as @hamedaligha commented:

https://stackoverflow.com/a/78233592/13086128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests