segmentation_models
segmentation_models copied to clipboard
module 'keras.utils' has no attribute 'get_file'
I'm trying to use segmentation models on google colab but I can't fix this error. I've searched for this particular one but couldn't find an answer. I'm using pycharm and this error is linked to this specific line of code BACKBONE = 'resnet34'
You can try: import segmentation_models as sm sm.set_framework('tf.keras') sm.framework()
It worked, thanks man!
hi @Dathn29 for me, the snippet didn't work
I have the same problem working in GOOGLE COLAB @Dathn29 solution is also not working to me Please help
@mudaser37 As per my understanding, the problem is related to the Keras version. I didn't work on this code, but I faced the same error in a different scenario. I tried on Kaggle and solved my issue. As you mentioned the above tricks are not working for you, so you can try to downgrade the Keras /TensorFlow versions to check if that works or try Kaggle.
I found below links, which are relevant as well.
https://stackoverflow.com/questions/67792138/attributeerror-module-keras-utils-has-no-attribute-get-file-using-segmentat
https://stackoverflow.com/questions/61137954/attributeerror-module-tensorflow-python-keras-utils-generic-utils-has-no-attr
https://stackoverflow.com/questions/67696508/attributeerror-module-keras-utils-generic-utils-has-no-attribute-populate-di
None of the above link is working. I am presenting my error which I am facing while training UNET model from library called segmentation_models on ubutnu os.
File "training_unet.py", line 67, in <module>
model = sm.Unet("resnet34", input_shape=(None, None, 3), classes=cityscapes_num_classes, activation="softmax")
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/__init__.py", line 34, in wrapper
return func(*args, **kwargs)
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/models/unet.py", line 221, in Unet
backbone = Backbones.get_backbone(
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/backbones/backbones_factory.py", line 103, in get_backbone
model = model_fn(*args, **kwargs)
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models_factory.py", line 78, in wrapper
return func(*args, **new_kwargs)
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models/resnet.py", line 314, in ResNet34
return ResNet(
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models/resnet.py", line 280, in ResNet
load_model_weights(model, model_params.model_name,
File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/weights.py", line 25, in load_model_weights
weights_path = keras_utils.get_file(
AttributeError: module 'keras.utils' has no attribute 'get_file'
None of the above link is working. I am presenting my error which I am facing while training UNET model from library called segmentation_models on ubutnu os.
File "training_unet.py", line 67, in <module> model = sm.Unet("resnet34", input_shape=(None, None, 3), classes=cityscapes_num_classes, activation="softmax") File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/__init__.py", line 34, in wrapper return func(*args, **kwargs) File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/models/unet.py", line 221, in Unet backbone = Backbones.get_backbone( File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/segmentation_models/backbones/backbones_factory.py", line 103, in get_backbone model = model_fn(*args, **kwargs) File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models_factory.py", line 78, in wrapper return func(*args, **new_kwargs) File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models/resnet.py", line 314, in ResNet34 return ResNet( File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/models/resnet.py", line 280, in ResNet load_model_weights(model, model_params.model_name, File "/home/samyak/anaconda3/envs/environment/lib/python3.8/site-packages/classification_models/weights.py", line 25, in load_model_weights weights_path = keras_utils.get_file( AttributeError: module 'keras.utils' has no attribute 'get_file'
https://stackoverflow.com/questions/69744983/attributeerror-module-keras-utils-has-no-attribute-get-file
It works for me, maybe you can try it.