无法使用 Tensorflow2.x 在 Colab 中导入 keras-vggface

问题描述 投票:0回答:1

我应该“导入keras_vggface”,它给出以下报告:自从Tensorflow升级到2.x,导入keras-vggface有很多问题。有谁知道怎么解决吗?

%tensorflow_version 2.x
!pip install keras-applications keras-preprocessing
!pip install keras-vggface
!pip install scikit-image
!pip install pydot
import keras_vggface




ImportError                               Traceback (most recent call last)
\<ipython-input-2-7a523c30fa3e\> in \<cell line: 1\>()
\----\> 1 import keras_vggface
2 print(keras_vggface.__file__)

2 frames
/usr/local/lib/python3.10/dist-packages/keras_vggface/models.py in \<module\>
14     AveragePooling2D, Reshape, Permute, multiply
15 from keras_applications.imagenet_utils import \_obtain_input_shape
\---\> 16 from keras.utils import layer_utils
17 from keras.utils.data_utils import get_file
18 from keras import backend as K

ImportError: cannot import name 'layer_utils' from 'keras.utils' (/usr/local/lib/python3.10/dist-packages/keras/api/utils/__init__.py)

---------------------------------------------------------------------------

NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.

我需要在 Cloab 中使用 Tensorflow2.x 成功导入 keras-vggface

tensorflow keras keras-vggface
1个回答
0
投票
新版本中keras不再支持

layer_utils
。我认为您应该尝试在仍受支持的情况下将
tensorflow
keras
安装到旧版本(
tensorflow==2.13.0
keras==2.12

pip install --force-reinstall tensorflow==2.13.0
pip install --force-reinstall keras==2.12
© www.soinside.com 2019 - 2024. All rights reserved.