python - Cannot run Object Detector issues on Windows (ImportError: cannot import name 'string_int_label_map_pb2' from 'object_detection.protos')
问题描述
I'm trying to setup the tensorflow OD package and I tried installing it from the repo, but it doesn't seem to be working.
I followed the installation steps (object_detection) and tried running the test files object_detection.builders.model_builder_tf2_test.py
with no avail.
- The
protoc
executable is not recognized - I got a
tf_utils missing
message at one point - And ended up with
ImportError: cannot import name 'string_int_label_map_pb2' from 'object_detection.protos'
I'm a novice playing with this tool, has anybody ran into these issues?
I found these related issues and tried several things, but each step I make forward unlocks another issue.
解决方案
After some attempts, starting from a new environment, I put together the steps to make it work.
Create Environment from YML
- Use this barebone setup to create a new environment (see snippet below)
- Clone the Object Detector (OD) repository
- Follow instructions here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md#python-package-installation
git clone https://github.com/tensorflow/models.git
- Follow instructions here: https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/tf2.md#python-package-installation
- Download protobuf (google) win64 ZIP
- https://github.com/protocolbuffers/protobuf/releases/download/v3.15.1/protoc-3.15.1-win64.zip
- unzip
- from
bin/
copyprotoc.exe
toC:\Windows\System32
- test by running
protoc
in command prompt
- Run code below from {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 .
- To validate setup, run either of the following
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
推荐阅读
- r - 是否可以仅为特定引擎设置块默认值?
- vb.net - 使用 Quick Shift 结果创建图像
- html - Can't stop all CSS animations on hover over one or another
- angular - sh: 0: 无法打开 /docker-entrypoint.sh
- google-drive-api - 授予作者权限时如何防止 Google Drive API v3 发送通知电子邮件?
- outlook - Outlook OnSend 插件是否支持 Service Worker?
- javascript - 简单计算器:函数中的值未定义但在条件中列出
- anylogic - 在流程中使用不同的托盘架,每个托盘架都有一个 ID
- python - 在 Python 中解析 FASTA 文件时遇到问题
- floating-point - 浮点数只能表示一组固定的数字?