创建TF记录
代码:
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'}
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x{IMAGE_PATH + '/test'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/test.record'}
错误:
Traceback (most recent call last):
File "Tensorflow/scripts/generate_tfrecord.py", line 29, in <module>
From object_detection.utils import dataset_util, label_map_util
ModuleNotFoundError: No module named 'object_detection'
Traceback (most recent call last):
File "Tensorflow/scripts/generate_tfrecord.py", line 29, in <module>
From object_detection.utils import dataset_util, label_map_util
ModuleNotFoundError: No module named 'object_detection'
我关注了尼古拉斯·雷诺特视频 https://youtu.be/pDXdlXlaCco@22:30
我从 git clone 下载了 Tensorflow object_detection 模型https://github.com/tensorflow/models
然后我就跑了
python -m install pip
之后
git clone https://github.com/tensorflow/models
你必须运行 protoc 才能正确安装 API:
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python -m pip install .
毕竟用这个脚本测试它:
python object_detection/builders/model_builder_tf2_test.py
如果你已经安装了相关的依赖项,比如protoc,如下
%cd /content/models/research
!protoc object_detection/protos/*.proto --python_out=.
你需要通过以下方式创建环境,
!pip install tf_slim
pwd = os.getcwd()
os.environ['PYTHONPATH'] += f':{pwd}:{pwd}/slim'
我遵循了@Jotunheim的建议
cd models/research/
protoc object_detection/protos/*.proto --python_out=.
cp object_detection/packages/tf2/setup.py .
python -m pip install .
尝试安装 PyYAML 5.4 时,第三个命令总是会失败
让它对我有用的是回到python3.9(3.10不起作用)并在运行第三行之前手动安装PyYAML 5.3.1
pip install PyYAML==5.3.1