有几个在线教程可以像这样从keras_vggface导入VGGFace模型:
from keras_vggface.vggface import VGGFace
但是,我得到了以下错误:
ModuleNotFoundError: No module named 'keras.engine.topology'
这个问题发生在我的本地机器上,但在安装了keras_vggface后,也发生在Google Colab上
keras_vggface
!pip install keras_vggface
3zwjbxry1#
我在Google Colab中解决了此问题,方法是将导入从
from keras.engine.topology import get_source_inputs
到
from keras.utils.layer_utils import get_source_inputs
在usr/local/lib/python3.7/dist-packages/keras_vggface/models.py中
usr/local/lib/python3.7/dist-packages/keras_vggface/models.py
dldeef672#
! pip install git+https://github.com/rcmalli/keras-vggface.git !pip install keras_applications --no-deps filename = "/usr/local/lib/python3.7/dist-packages/keras_vggface/models.py" text = open(filename).read() open(filename, "w+").write(text.replace('keras.engine.topology', 'tensorflow.keras.utils')) import tensorflow as tf from keras_vggface.vggface import VGGFace vggface = VGGFace(model='resnet50') # or VGGFace() as default
为我和colab工作
798qvoo83#
我认为你需要安装如下:
应该可以
omjgkv6w4#
Made following Changes in C:\Users\deepa\AppData\Local\Programs\Python\Python39\Lib\site-packages\keras_vggface\models.py
4条答案
按热度按时间3zwjbxry1#
我在Google Colab中解决了此问题,方法是将导入从
到
在
usr/local/lib/python3.7/dist-packages/keras_vggface/models.py
中dldeef672#
为我和colab工作
798qvoo83#
我认为你需要安装如下:
应该可以
omjgkv6w4#
Made following Changes in C:\Users\deepa\AppData\Local\Programs\Python\Python39\Lib\site-packages\keras_vggface\models.py