问题描述
我正在尝试设置 tensorflow OD 包,并尝试从 repo 安装它,但它似乎不起作用。
我按照安装步骤 (object_detection) 操作并尝试运行测试文件 object_detection.builders.model_builder_tf2_test.py
,但无济于事。
- 无法识别
protoc
可执行文件 - 我曾收到一条
tf_utils missing
消息 - 最后得到了
ImportError: cannot import name 'string_int_label_map_pb2' from 'object_detection.protos'
我是这个工具的新手,有人遇到过这些问题吗?
我发现了这些相关问题并尝试了几件事,但我向前迈出的每一步都会解开另一个问题。
- Object Detection API error: "ImportError: cannot import name anchor_generator_pb2"
- https://github.com/tensorflow/models/issues/2930
解决方法
经过一些尝试,从一个新环境开始,我整理了使其工作的步骤。
从 YML 创建环境
- 使用此准系统设置创建新环境(请参阅下面的代码段)
- 克隆对象检测器 (OD) 存储库
- 按照此处的说明操作:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md#python-package-installation
git clone https://github.com/tensorflow/models.git
- 按照此处的说明操作:https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md#python-package-installation
- 下载 protobuf (google) win64 ZIP
- https://github.com/protocolbuffers/protobuf/releases/download/v3.15.1/protoc-3.15.1-win64.zip
- 解压
- 从
bin/
复制protoc.exe
到C:\Windows\System32
- 通过在命令提示符下运行
protoc
进行测试
- 从 {rootdir} 运行下面的代码
cd models/research # Compile protos. protoc object_detection/protos/*.proto --python_out=. # Install TensorFlow Object Detection API. cp object_detection\packages\tf2\setup.py . # Step below is important even if some comments online (2021-02-23) suggest it is deprecated python -m pip install --use-feature=2020-resolver . # The step below was added,after unsuccessful previous attempts,from [this related issue][1] pip install .
- 要验证设置,请运行以下任一操作
python object_detection.builders.model_builder_tf2_test.py
import object_detection.builders.model_builder_tf2_test
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
@EXPLICIT
https://repo.anaconda.com/pkgs/main/win-64/ca-certificates-2021.1.19-haa95532_0.conda
https://repo.anaconda.com/pkgs/main/win-64/vs2015_runtime-14.27.29016-h5e58377_2.conda
https://repo.anaconda.com/pkgs/main/win-64/vc-14.2-h21ff451_1.conda
https://repo.anaconda.com/pkgs/main/win-64/openssl-1.1.1i-h2bbff1b_0.conda
https://repo.anaconda.com/pkgs/main/win-64/zlib-1.2.11-h62dcd97_4.conda
https://repo.anaconda.com/pkgs/main/win-64/sqlite-3.33.0-h2a8f88b_0.conda
https://repo.anaconda.com/pkgs/main/win-64/python-3.8.0-hff0d562_2.conda
https://repo.anaconda.com/pkgs/main/win-64/certifi-2020.12.5-py38haa95532_0.conda
https://repo.anaconda.com/pkgs/main/noarch/wheel-0.36.2-pyhd3eb1b0_0.conda
https://repo.anaconda.com/pkgs/main/win-64/wincertstore-0.2-py38_0.conda
https://repo.anaconda.com/pkgs/main/win-64/setuptools-52.0.0-py38haa95532_0.conda
https://repo.anaconda.com/pkgs/main/win-64/pip-20.3.3-py38haa95532_0.conda