无法在 Windows 上运行对象检测器问题导入错误:无法从“object_detection.protos”导入名称“string_int_label_map_pb2” 从 YML 创建环境

问题描述

我正在尝试设置 tensorflow OD 包,并尝试从 repo 安装它,但它似乎不起作用。

我按照安装步骤 (object_detection) 操作并尝试运行测试文件 object_detection.builders.model_builder_tf2_test.py,但无济于事。

  1. 无法识别 protoc 可执行文件
  2. 我曾收到一条 tf_utils missing 消息
  3. 最后得到了 ImportError: cannot import name 'string_int_label_map_pb2' from 'object_detection.protos'

我是这个工具的新手,有人遇到过这些问题吗?

我发现了这些相关问题并尝试了几件事,但我向前迈出的每一步都会解开另一个问题。

解决方法

经过一些尝试,从一个新环境开始,我整理了使其工作的步骤。

从 YML 创建环境

  1. 使用此准系统设置创建新环境(请参阅下面的代码段)
  2. 克隆对象检测器 (OD) 存储库
  3. 下载 protobuf (google) win64 ZIP
  4. 从 {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 .
    
  5. 要验证设置,请运行以下任一操作
    • 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...