segmentation_models
segmentation_models copied to clipboard
Module 'keras.utils' has no attribute 'get_file'
Hi, when I'm trying to load the weights of imagenet in any model it's showing me an error that says "module 'keras.utils' has no attribute 'get_file'.
I also tried sm.set_framework("tf.keras") but it's throwing an error that says there is no method named set_framework in segmentation_model.
what can be done to solve this ?
Same problem here. Are you also using Google Colab?
No, I'm using a local system
Hello. I suspect you are using the latest tensorflow (my tf.__version__
is 2.6.0 and I have this issue). This fixes it for me:
import os
os.environ['SM_FRAMEWORK'] = 'tf.keras'
import segmentation_models as sm
Then it should print:
Segmentation Models: using 'tf.keras' framework
Hope that helps.
Looking further, it seems the sm.set_framework('tf.keras')
does work for me:
import os
# os.environ['SM_FRAMEWORK'] = 'tf.keras'
import segmentation_models as sm
print('sm.version=' + sm.__version__)
sm.set_framework('tf.keras')
model = sm.Unet('efficientnetb0', classes=1, input_shape=(128, 128, 3),
decoder_filters=(512, 256, 128, 64, 32), activation='sigmoid')
output:
Segmentation Models: using `keras` framework.
sm.version=1.0.1
Maybe a version mismatch or import issue? Again, hope this helps as a comparison point.
Looking further, it seems the
sm.set_framework('tf.keras')
does work for me:import os # os.environ['SM_FRAMEWORK'] = 'tf.keras' import segmentation_models as sm print('sm.version=' + sm.__version__) sm.set_framework('tf.keras') model = sm.Unet('efficientnetb0', classes=1, input_shape=(128, 128, 3), decoder_filters=(512, 256, 128, 64, 32), activation='sigmoid')
output:
Segmentation Models: using `keras` framework. sm.version=1.0.1
Maybe a version mismatch or import issue? Again, hope this helps as a comparison point.
OHHHHHHHHHHHHHHHHHHHHH, it does works for me .thank you very much !great!