我刚刚开始学习如何在Google Colab的Tensorflow对象检测API中使用ML模型,所以我试图非常仔细地遵循文档。在安装了库和包之后,我使用https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html:
中的命令测试安装情况python object_detection/builders/model_builder_tf2_test.py
但是我得到以下错误:
Traceback (most recent call last):
File "object_detection/builders/model_builder_tf2_test.py", line 24, in <module>
from object_detection.builders import model_builder
File "/usr/local/lib/python3.7/dist-packages/object_detection/builders/model_builder.py", line 37, in <module>
from object_detection.meta_architectures import deepmac_meta_arch
File "/usr/local/lib/python3.7/dist-packages/object_detection/meta_architectures/deepmac_meta_arch.py", line 20, in <module>
from object_detection.models.keras_models import resnet_v1
File "/usr/local/lib/python3.7/dist-packages/object_detection/models/keras_models/resnet_v1.py", line 28, in <module>
from keras.applications import resnet # pylint:disable=g-import-not-at-top
File "/usr/local/lib/python3.7/dist-packages/keras/__init__.py", line 25, in <module>
from keras import models
File "/usr/local/lib/python3.7/dist-packages/keras/models.py", line 20, in <module>
from keras import metrics as metrics_module
File "/usr/local/lib/python3.7/dist-packages/keras/metrics.py", line 27, in <module>
from keras import activations
File "/usr/local/lib/python3.7/dist-packages/keras/activations.py", line 20, in <module>
from keras.layers import advanced_activations
File "/usr/local/lib/python3.7/dist-packages/keras/layers/__init__.py", line 93, in <module>
from keras.layers.core import Masking
File "/usr/local/lib/python3.7/dist-packages/keras/layers/core/__init__.py", line 20, in <module>
from keras.layers.core.dropout import Dropout
File "/usr/local/lib/python3.7/dist-packages/keras/layers/core/dropout.py", line 26, in <module>
class Dropout(base_layer.BaseRandomLayer):
AttributeError: module 'keras.engine.base_layer' has no attribute 'BaseRandomLayer'
即使在导入keras 2.0版本后,它仍然不工作,我能做些什么来解决这个问题,谢谢
解决了:tensorflow 2.5.0版本与提供的代码不兼容。我必须安装2.8.0才能运行