Open AbtinDjavadifar opened 4 years ago
What version of Keras do you have installed? Is it the same as the version required by the version of Segmentation Models you currently have installed?
same here
File "/home/nvidia/pellame-g4f/lam/backend/lambackend/services/analysis_svc.py", line 6, in <module>
import segmentation_models as sm
File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/segmentation_models/__init__.py", line 98, in <module>
set_framework(_framework)
File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/segmentation_models/__init__.py", line 68, in set_framework
import efficientnet.keras # init custom objects
File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/efficientnet/keras.py", line 17, in <module>
init_keras_custom_objects()
File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/efficientnet/__init__.py", line 71, in init_keras_custom_objects
keras.utils.generic_utils.get_custom_objects().update(custom_objects)
AttributeError: module 'keras.utils' has no attribute 'generic_utils'
Installed versions (inside a v.env. on Jetson TX2):
What version of Keras do you have installed? Is it the same as the version required by the version of Segmentation Models you currently have installed?
Yes, it's the same.
same here
File "/home/nvidia/pellame-g4f/lam/backend/lambackend/services/analysis_svc.py", line 6, in <module> import segmentation_models as sm File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/segmentation_models/__init__.py", line 98, in <module> set_framework(_framework) File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/segmentation_models/__init__.py", line 68, in set_framework import efficientnet.keras # init custom objects File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/efficientnet/keras.py", line 17, in <module> init_keras_custom_objects() File "/home/nvidia/virtualenvs/venv_lam/lib/python3.6/site-packages/efficientnet/__init__.py", line 71, in init_keras_custom_objects keras.utils.generic_utils.get_custom_objects().update(custom_objects) AttributeError: module 'keras.utils' has no attribute 'generic_utils'
Installed versions (inside a v.env. on Jetson TX2):
- Keras 2.4.3
- Keras-Applications 1.0.8
- segmentation-models 1.0.1
- tensorflow 2.2.0+nv20.6
I changed keras.utils.generic_utils.get_custom_objects().update(custom_objects)
to keras.utils.get_custom_objects().update(custom_objects)
in .../lib/python3.6/site-packages/efficientnet/__init__.py
and it solved the issue.
TLDR : export SM_FRAMEWORK=tf.keras before running your code.
error happens in efficientnet.keras package but not in efficientnet.tfkeras. But importing segmentation_models initializes keras backend by default as per (Line 48, segmentation_models/init.py):
def framework(): """Return name of Segmentation Models framework"""
return _KERAS_FRAMEWORK
So, sm.set_framework cannot be called before this error happens. You can either modify the init.py to return _TF_KERAS_FRAMEWORK_NAME or export it in command line as follows. export SM_FRAMEWORK=tf.keras before running your code.
On Thu, Jul 23, 2020 at 12:26 PM Zhanglibingo notifications@github.com wrote:
you can install tensorflow-gpu by conda install tensorflow-gpu==1.14.0 again.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/qubvel/segmentation_models/issues/374#issuecomment-662848300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFCHUQMKU7D2LK6D73456DR47NIBANCNFSM4PBUBKTQ .
@qubvel Can someone have a look? We are unable to reuse your code. (Practically we can via forking your code.) But it is better if we can fix it in stable branch.
Hi, I used segmentation-models for building segmentation in google Colab . my code worked correctly until yesterday. But today I have this error: AttributeError: module 'keras.utils' has no attribute 'generic_utils' How can i fix it?
@JordanMakesMaps any update? Can you please provide workaround? I believed requirements.txt should be correct atleast to make it work!
Hi all this is the correct requirements to make it working! working after multiple trial and errors. !pip install keras==2.3.1 !pip install tensorflow==2.1.0 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0
Hi all this is the correct requirements to make it working! working after multiple trial and errors. !pip install keras==2.3.1 !pip install tensorflow==2.1.0 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0
Thanks. Could you start training using tf.keras instead of keras? I really need to do that as I want to convert the trained model to tf lite and the training has to be done via tf.keras.
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
tensorflow = "<2.3" keras = "<2.4" albumentations = "==0.4.6" segmentation-models = "==1.0.1"
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
This solved it for me on Google Colab. You are a life saver.
downgrade the tensorflow to 2.1.0
pip install tensorflow==2.1.0
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
Solved my problem on Kaggle thank you.
Hi all this is the correct requirements to make it working! working after multiple trial and errors. !pip install keras==2.3.1 !pip install tensorflow==2.1.0 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0
Thanks @vikalpjain91. Uninstalling everything, then downloading/installing in this order: tensorflow keras segmentation-models
worked for me.
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
IT worked for me
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
It works.Thanks a lot!
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
big thanks this work to me
Hi all this is the correct requirements to make it working! working after multiple trial and errors. !pip install keras==2.3.1 !pip install tensorflow==2.1.0 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0
Thanks dude
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
Worked for me ! Thanks
%env SM_FRAMEWORK=tf.keras try this before importing segmentation models , it solved my problem.
Worked for me ! Thanks
this works
I ran into the same problem (using tensorflow 2.3.2) and I can't downgrade TF due to other dependencies. Is there any chance that this codebase is getting an update so that the more current versions of TF can be used with it?
I ran into the same problem (using tensorflow 2.3.2) and I can't downgrade TF due to other dependencies. Is there any chance that this codebase is getting an update so that the more current versions of TF can be used with it?
Replacing all instances of
import keras.whatever
with
import tensorflow.keras.whatever
Fixes the issue for me in tensorflow 2.4.0 and 2.5.0-rc1.
Please create a PR if you cone up with solution
For kaggle installing in this order solved my issue:- !pip install tensorflow==2.1.0 !pip install keras==2.3.1 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0 !pip install -U segmentation-models==1.0.1
%env SM_FRAMEWORK=tf.keras
Link to kaggle notebook - https://www.kaggle.com/shubhamdivakar/qubvel-segmentation-code/
I have the same issue, but i try above of them. !pip install tensorflow==2.1.0 !pip install keras==2.3.1 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0 !pip install -U segmentation-models==1.0.1
%env SM_FRAMEWORK=tf.keras
But I try it on jupyter notebook still has the problem. Is there has any method to fix it?
I have the same issue, but i try above of them. !pip install tensorflow==2.1.0 !pip install keras==2.3.1 !pip install keras_applications==1.0.8 !pip install image-classifiers==1.0.0 !pip install efficientnet==1.0.0 !pip install -U segmentation-models==1.0.1
%env SM_FRAMEWORK=tf.keras
But I try it on jupyter notebook still has the problem. Is there has any method to fix it?
I have not worked on the Jupyter notebook but for the kaggle %env SM_FRAMEWORK=tf.keras woks fine.
I ran into the same problem (using tensorflow 2.3.2) and I can't downgrade TF due to other dependencies. Is there any chance that this codebase is getting an update so that the more current versions of TF can be used with it?
Replacing all instances of
import keras.whatever
withimport tensorflow.keras.whatever
Fixes the issue for me in tensorflow 2.4.0 and 2.5.0-rc1.
While converting from keras to tensorflow.keras, I am facing some issues like cannot convert following;
from keras.engine.topology import Network
Can you help me how to convert it to tf.keras. Tq.
import os
os.environ["SM_FRAMEWORK"] = "tf.keras" #before the import
from segmentation_models import PSPNet
Solved the issue for me
I am using Keras from TensorFlow. Using TensorFlow 2.5, no problem after following:
Option 1: In the start of notebook, change the environment variable as
%env SM_FRAMEWORK=tf.keras
Option 2: Another way to change environment variable.
import segmentation_models as sm
sm.set_framework('tf.keras')
Problem solved for TensorFlow 2.5.
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
Thank you saviour .
%env SM_FRAMEWORK=tf.keras try this before importing segmentation models , it solved my problem.
This solved it for me on Google Colab. You are a life saver.
Worked for me as well!
%env SM_FRAMEWORK=tf.keras try this before importing segmentation models , it solved my problem.
This solved it for me on Google Colab. You are a life saver.
This also solved it for me, thanks!
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
It also worked for me, could you please explain what this does?
hi! i work on google colab and I tried all the given solution but still has the problem. pleas i need help
hi! i work on google colab and I tried all the given solution but still has the problem. pleas i need help
Try the other option.
Option 1: In the start of notebook, change the environment variable as %env SM_FRAMEWORK=tf.keras
Option 2: Another way to change environment variable. import segmentation_models as sm sm.set_framework('tf.keras')
It refers to changes in new version of keras while segmentation model is built with older versions of keras In Linux I ran these codes :
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
it works.
%env SM_FRAMEWORK=tf.keras
try this before importing segmentation models , it solved my problem.
Thanks! it works for me.
Hi,
I'm trying to run
multiclass segmentation (camvid).ipynb
example and get an error after running the following block:Here is the error:
Can anyone help me to solve this?