ImportError:无法导入名称“ string_int_label_map_pb2”

송준석*_*송준석 5 python tensorflow imagenet

我使用以下命令编译了文件。

protoc object_detection/protos/*.proto --python_out=.
Run Code Online (Sandbox Code Playgroud)

结果编译成.py文件。

但是,我收到以下错误代码。

〜/ Documents / imgmlreport / inception / classification_inception / models / research / object_detection / utils / label_map_util.py在()中

 20 import tensorflow as tf
 21 from google.protobuf import text_format
---> 22 from object_detection.protos import string_int_label_map_pb2
 23 
 24 

ImportError: cannot import name 'string_int_label_map_pb2'
Run Code Online (Sandbox Code Playgroud)

所以我检查了utils,我已经有了一个string_int_label_map_pb2.py

为什么不能导入string_int_label_map_pb2.py?

小智 2

你使用的是conda环境吗?

在这种情况下,指向的 protoc 文件夹位于 C:\Users\xx\anaconda3\envs\xx\Lib\site-packages\protos 中

您应该将 protoc 的内容从 Models\reserach 复制到此中