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

ImageAI on colab #693

Closed
epistimi4 opened this issue Aug 20, 2021 · 3 comments
Closed

ImageAI on colab #693

epistimi4 opened this issue Aug 20, 2021 · 3 comments

Comments

@epistimi4
Copy link

epistimi4 commented Aug 20, 2021

Hi all,

I am trying to run the folwoing example from the wiki in Google colab. I initialize the environment as it is stated on the readme file and I get the error about tensorfolow.

My code:

`from imageai.Detection.Custom import DetectionModelTrainer

trainer = DetectionModelTrainer()
trainer.setModelTypeAsYOLOv3()
trainer.setDataDirectory(data_directory="hololens")
metrics = trainer.evaluateModel(model_path="hololens/models", json_path="hololens/json/detection_config.json", iou_threshold=0.5, object_threshold=0.3, nms_threshold=0.5)
print(metrics)`

Initialization
!pip install tensorflow-gpu==1.13.1 !sudo apt-get purge nvidia* !sudo wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64 !sudo dpkg -i cuda-repo-ubuntu1604-10-0-local-10.0.130-410.48_1.0-1_amd64 !sudo apt-key add /var/cuda-repo-/7fa2af80.pub !sudo apt-get update !sudo apt-get install cuda=10.0.130-1

Error:
ImportError: cannot import name 'RegisterShape' from 'tensorflow.python.framework.ops' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/ops.py)

Alternative initialization
`!update-alternatives --install /usr/bin/python python /usr/bin/python3.7.6
!pip install tensorflow-gpu==2.4.0
!pip install keras==2.4.3 numpy==1.19.3 pillow==7.0.0 scipy==1.4.1 h5py==2.10.0 matplotlib==3.3.2 opencv-python keras-resnet==0.2.0

!pip install imageai --upgrade`

Error
`--> 177 from tensorflow.python.keras.layers.normalization import LayerNormalization
178 from tensorflow.python.keras.layers.normalization_v2 import SyncBatchNormalization
179

ImportError: cannot import name 'LayerNormalization' from 'tensorflow.python.keras.layers.normalization' (/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/normalization/init.py)`

And the same error with the following initialization:

!pip install tensorflow-gpu==2.4.0 !pip install tensorflow-gpu==2.5.0rc0 !pip install folium==0.2.1 !pip install imgaug==0.2.6 !pip install bokeh==2.3.0 !pip install keras==2.5.0rc0 numpy==1.19.3 pillow==7.0.0 scipy==1.4.1 h5py==2.10.0 matplotlib==3.3.2 opencv-python keras-resnet==0.2.0 !pip install imageai --upgrade

Could someone please help me on the correct initialization for Colab?

@ekesdf
Copy link

ekesdf commented Aug 20, 2021

can you share the link to your notebook you ran to get this thy

@epistimi4
Copy link
Author

@epistimi4
Copy link
Author

I needed to restart runtime in Colab and finally it was fixed with the following initialization

!pip install tensorflow-gpu==2.5.0rc0
!pip install folium==0.2.1
!pip install imgaug==0.2.6
!pip install bokeh==2.3.0
!pip install keras==2.5.0rc0 numpy==1.19.3 pillow==7.0.0 scipy==1.4.1 h5py==2.10.0 matplotlib==3.3.2 opencv-python keras-resnet==0.2.0
!pip install imageai --upgrade

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

2 participants