ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

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...

ความคิดเห็น • 19

  • @juansebastian6284
    @juansebastian6284 3 ปีที่แล้ว +3

    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

  • @vivekyadav-eb1ic
    @vivekyadav-eb1ic 2 ปีที่แล้ว

    a simple but very useful tricks, with simple way of explanation. very nice...

  • @oo_wais
    @oo_wais ปีที่แล้ว

    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

  • @oliviertina4169
    @oliviertina4169 5 หลายเดือนก่อน

    Thank you for these tricks.

  • @waqascheema2143
    @waqascheema2143 9 หลายเดือนก่อน

    Thank you so much, you are life saver.

  • @lee-qk2vk
    @lee-qk2vk 3 หลายเดือนก่อน

    You sir are AMAZING!

  • @rezatabrizi4390
    @rezatabrizi4390 3 ปีที่แล้ว +1

    thank you for this information

  • @SS-zq5sc
    @SS-zq5sc ปีที่แล้ว

    You are the best.

  • @ghymes1999
    @ghymes1999 ปีที่แล้ว

    Thank you sir :)

  • @umairsabir6686
    @umairsabir6686 3 ปีที่แล้ว

    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

  • @dantec.dagandanan3732
    @dantec.dagandanan3732 2 ปีที่แล้ว

    module 'keras.utils' has no attribute 'get_file' how about this ser?

    • @DigitalSreeni
      @DigitalSreeni  2 ปีที่แล้ว +1

      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()

  • @XX-vu5jo
    @XX-vu5jo 3 ปีที่แล้ว

    module 'keras.utils' has no attribute 'get_file' this is my error when I did your method it just ruined everything

    • @DigitalSreeni
      @DigitalSreeni  3 ปีที่แล้ว

      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?

    • @XX-vu5jo
      @XX-vu5jo 3 ปีที่แล้ว +1

      @@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.

    • @muhammadfahad847
      @muhammadfahad847 3 ปีที่แล้ว

      Yes sir i am facing this issue too please help

    • @XX-vu5jo
      @XX-vu5jo 3 ปีที่แล้ว

      @@muhammadfahad847 don’t use keras use tensorflow.keras and np.utils.

  • @talha_anwar
    @talha_anwar 3 ปีที่แล้ว

    lol, i spend a day to convert the whole code from TF1.x to TF2.x