Dro*_*dux 4 python image-segmentation keras tensorflow
I am working on google colab with the segmentation_models library. It worked perfectly the first week using it, but now it seems that I can't import the library anymore. Here is the error message, when I execute import segmentation_models as sm :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-6f48ce46383f> in <module>
1 import tensorflow as tf
----> 2 import segmentation_models as sm
3 frames
/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'
Run Code Online (Sandbox Code Playgroud)
Colab uses tensorflow version 2.11.0.
I did not find any information about this particular error message. Does anyone know where the problem may come from ?
小智 8
谢谢,它有效,但我刚刚这样做了:
import os
os.environ["SM_FRAMEWORK"] = "tf.keras"
from tensorflow import keras
import segmentation_models as sm
Run Code Online (Sandbox Code Playgroud)
尝试这个。有用。我在谷歌colab上查了一下
!pip install -U -q segmentation-models
!pip install -q tensorflow==2.2.1
!pip install -q keras==2.5
import os
os.environ["SM_FRAMEWORK"] = "tf.keras"
from tensorflow import keras
import segmentation_models as sm
Run Code Online (Sandbox Code Playgroud)
小智 6
有时遇到同样的问题。我是如何解决的:
打开文件 keras.py,将所有 'init_keras_custom_objects' 更改为 'init_tfkeras_custom_objects'。
keras.py 的位置在错误消息中。在您的情况下,它应该位于 /usr/local/lib/python3.8/dist-packages/efficientnet/ 中
| 归档时间: |
|
| 查看次数: |
10809 次 |
| 最近记录: |