ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
Python tips and tricks - 6: Fixing generic_utils error while importing segmentation models library
ฝัง
- เผยแพร่เมื่อ 29 มี.ค. 2021
- Note: Importing segmentation models library may give you generic_utils
error on TF2.x
If you get an error about generic_utils...
change
keras.utils.generic_utils.get_custom_objects().update(custom_objects)
to
keras.utils.get_custom_objects().update(custom_objects)
in
.../lib/python3.7/site-packages/efficientnet/__init__.py
For Anaconda users:
Use this code to find out the location of site-packages directory
under your current environment in anaconda.
from distutils.sysconfig import get_python_lib
print(get_python_lib())
For Colab users:
You can click on the direct link provided on Colab for __init__.py and edit it.
Remember to restart the runtime after editing the file.
Alternatively you can work with Tensorflow 1.x that doesn't throw
the generic_utils error.
In google colab, add this as your first line.
%tensorflow_version 1.x
(Or just create a new environment in your local IDE to use TF1.x)
Code generated in the video can be downloaded from here:
github.com/bns...
This issue also occurs in Kaggle. It can be fixed by running this line:
%env SM_FRAMEWORK=tf.keras
Before this one:
!pip install segmentation-models
These two lines must be executed always at the beggining of the code. I don't know if there is another way, but it worked for me
Thank you!!! Worked for me as well.
a simple but very useful tricks, with simple way of explanation. very nice...
thanks a lot for making this video, i just ran into this problem and i had no idea how could i fix it... i have been watching your videos for a while now and they really helped me a lot in understanding and implementing segmentation. thanks again
Thank you for these tricks.
Thank you so much, you are life saver.
You sir are AMAZING!
thank you for this information
You are the best.
Thank you sir :)
Hi Sreeni, it will be great if you can please make a video on ANOGAN. There has been a challenge to detect anomalous pixels within an image by just training the normal data. Autoencoder does not work well in most cases as the lighting conditions change in manufacturing environement. May you have some other good suggestion. But I saw ANOGAN, DCGAN is answer to those question but it is hard for us to implement that algorithm with good accuracy and parameters. Thanks
module 'keras.utils' has no attribute 'get_file' how about this ser?
Try tensorflow version 2.4.
Also, try the following to set the framework. I hope one of these would fix the issue.
import segmentation_models as sm
sm.set_framework('tf.keras')
sm.framework()
module 'keras.utils' has no attribute 'get_file' this is my error when I did your method it just ruined everything
What do you mean it ruined everything, can you please explain so others do not run into same issue? I tested this on 2 desktops, one laptop and Colab with no issues. If you are running into issues there must be a scenario that I haven't encountered. Can you please provide the details of TensorFlow and Keras versions?
@@DigitalSreeni I used np.utils and used tensorflow.keras it worked now I got it working fine now. This method did not work for me.
Yes sir i am facing this issue too please help
@@muhammadfahad847 don’t use keras use tensorflow.keras and np.utils.
lol, i spend a day to convert the whole code from TF1.x to TF2.x