Google 机器学习引擎 preprocessor_pb2 导入错误

Google ML Engine preprocessor_pb2 ImportError

我正在尝试 运行 通过 Google 的机器学习引擎进行训练。

我主要按照以下文章中的步骤来开发我的训练和测试集: https://towardsdatascience.com/build-a-taylor-swift-detector-with-the-tensorflow-object-detection-api-ml-engine-and-swift-82707f5b4a56

我不断地运行进入以下错误:

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/root/.local/lib/python2.7/site-packages/object_detection/train.py", line 49, in <module> from object_detection import trainer File "/root/.local/lib/python2.7/site-packages/object_detection/trainer.py", line 27, in <module> from object_detection.builders import preprocessor_builder File "/root/.local/lib/python2.7/site-packages/object_detection/builders/preprocessor_builder.py", line 21, in <module> from object_detection.protos import preprocessor_pb2 ImportError: cannot import name preprocessor_pb2

我克隆并遵循 object_detection 的安装步骤,包括 protobuf 编译和设置 PYTHONPATH!该示例 model_builder_test.py 在控制台中也 运行 没问题。

我的训练工作如下:

gcloud ml-engine jobs submit training my_training_job \
--job-dir=gs://myapp.appspot.com/train \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz \
--module-name object_detection.train \
--region us-central1 \
--config object_detection/samples/cloud/cloud.yml \
-- \
--train_dir=gs://myapp.appspot.com/train \
--pipeline_config_path=gs://myapp.appspot.com/data/ssd_mobilenet_v1_coco.config

python -v 在控制台中 returns 版本 2.7

我想我通过将运行时版本降低到 1.2 解决了这个问题:

gcloud ml-engine jobs submit training my_training_job \
--runtime-version 1.2 \
--job-dir=gs://myapp.appspot.com/train \
--packages dist/object_detection-0.1.tar.gz,slim/dist/slim-0.1.tar.gz \
--module-name object_detection.train \
--region us-central1 \
--config object_detection/samples/cloud/cloud.yml \
-- \
-- train_dir=gs://myapp.appspot.com/train \
-- pipeline_config_path=gs://myapp.appspot.com/data/ssd_mobilenet_v1_coco.config

我随后收到有关缺少 matplotlib 的错误,并将以下行更改为

models/research/setup.py

REQUIRED_PACKAGES = ['Pillow>=1.0', 'matplotlib']

并重新运行:

python setup.py sdist
(cd slim && python setup.py sdist)

我等不及 Google 发布更多工具来简化培训工作流程!