无法从“object_detection”导入名称“model_lib_v2”

Gil*_*son 3 tensorflow

我正在尝试训练 TF2 进行对象检测。当我运行 model_main_tf2.py 时,出现以下错误:

Traceback (most recent call last):
  File "C:\Python_venv\trained_models\model_main_tf2.py", line 32, in <module>
    from object_detection import model_lib_v2
ImportError: cannot import name 'model_lib_v2' from 'object_detection' (c:\Python_venv\tensorflow\lib\site-packages\object_detection\__init__.py)
Run Code Online (Sandbox Code Playgroud)

如何安装 model_lib_v2?

我尝试重新安装 TF 并重新安装 TensorFlow-object-detection-API,但没有成功。我在互联网上到处寻找答案。

我发现: https: //github.com/tensorflow/models/issues/7920 但他们没有说如何安装 model_lib_v2

不幸的是我不能使用 TF1,目标是使用 TF2。

ais*_*ver 7

请参阅https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md

git clone https://github.com/tensorflow/models.git

## Python Package Installation
cd models/research
### Compile protos.

protoc object_detection/protos/*.proto --python_out=.
### Install TensorFlow Object Detection API.
cp object_detection/packages/tf2/setup.py .
python3 -m pip install --user --use-feature=2020-resolver .
Run Code Online (Sandbox Code Playgroud)