Open usher233 opened 1 year ago
The same to me:
/usr/local/lib/python3.8/dist-packages/efficientnet/init.py in init_keras_custom_objects() 69 } 70 71 keras.utils.generic_utils.get_custom_objects().update(custom_objects) 72 73
"AttributeError: module 'keras.utils.generic_utils' has no attribute 'get_custom_objects'"
Keras version 2.11.0? Google Colab?
!pip install keras==2.10.0
import keras
print(keras.__version__)
!pip install tensorflow==2.6.4
import tensorflow as tf
print(tf.__version__)
!pip install tensorflow==2.9.0 also works - thanks
It worked! Thanks!
Installing an older TF/Keras version is just a workaround. Can we get segmentation models to support TF 2.11?
I am using tensorflow 2.12 and got this to work by setting the env variable SM_FRAMEWORK="tf.keras"
I am using tensorflow 2.12 and got this to work by setting the env variable SM_FRAMEWORK="tf.keras"
Thanks for this @lucaslcode ! Was having trouble deploying an image segmentation model on hugging faces. I'd like to add to this. When I ran the code in Google Colab, I replaced all the instances of 'init_keras_custom_objects' in keras.py with 'init_tfkeras_custom_objects' and got it running on there and used tensorflow 2.11.0
# Open the file in write mode
with open('/usr/local/lib/python3.9/dist-packages/efficientnet/keras.py', 'r') as f:
# Read the contents of the file
contents = f.read()
# Replace the string
new_contents = contents.replace('init_keras_custom_objects', 'init_tfkeras_custom_objects')
# Open the file in write mode again and write the modified contents
with open('/usr/local/lib/python3.9/dist-packages/efficientnet/keras.py', 'w') as f:
f.write(new_contents)
Hi just import this line os.environ["SM_FRAMEWORK"] = "tf.keras"
Hi just import this line os.environ["SM_FRAMEWORK"] = "tf.keras"
Thank you, that is my current solution. However it would be better if segmentation models would support the newest TF versions.
A few days ago, I can still use it however today when I import segmentation_models this happened. I wander how can I fix this?