问题描述
我正在尝试使用Tensorflow对象检测API,并且已经成功测试了安装,但是我尝试使用给定的命令生成PASCAL VOC TFRecord文件
I'm trying to use the Tensorflow Object Detection API and I've successfully tested the installation,but we I try to generate the PASCAL VOC TFRecord files with the given command
python object_detection/create_pascal_tf_record.py \
--label_map_path=object_detection/data/pascal_label_map.pbtxt \
--data_dir=VOCdevkit --year=VOC2012 --set=train \
--output_path=pascal_train.record
我遇到以下错误:
Traceback (most recent call last):
File "object_detection/create_pascal_tf_record.py", line 36, in <module>
from object_detection.utils import dataset_util
ImportError: No module named object_detection.utils
我的PYTHONPATH是:
my PYTHONPATH is:
:/usr/local/lib/python2.7/dist-packages/tensorflow/models:/usr/local/lib/python2.7/dist-packages/tensorflow/models/slim
我正在/models目录中运行上述命令,知道如何解决此问题的人吗?
and I'm running the above command in the /models directory,anyone who knows how to fix this problem?
推荐答案
最好将"object_detection"添加到env路径中,而不是在python脚本中.
It's better for you to add 'object_detection' to the env path, not in the python script.
您可以在外壳中的"object_detection"目录中执行此操作.
You can do this in the shell, at the 'object_detection' directory.
export PYTHONPATH=$PYTHONPATH:`pwd`
或将路径添加到.bashrc/.zshrc(取决于您的shell),因此无需每次都导出.
Or add the path to .bashrc/.zshrc (depend on your shell), so don‘t need to export every time.
echo "export PYTHONPATH=$PYTHONPATH:`pwd` >> ~/.bashrc
这篇关于生成PASCAL TFRecord文件时的tensorflow对象检测API ImportError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!