Google Cloud ML使用对象检测模型返回空预测 [英] Google Cloud ML returns empty predictions with object detection model
问题描述
我是第一次将模型部署到Google Cloud ML.我已经在本地训练和测试了该模型,它仍然需要工作,但是可以.
I am deploying a model to Google Cloud ML for the first time. I have trained and tested the model locally and it still needs work but it works ok.
我已将其上传到Cloud ML,并使用我在本地测试的相同示例图像进行了测试,这些图像我知道会被检测到. (使用
I have uploaded it to Cloud ML and tested with the same example images I test locally that I know get detections. (using this tutorial)
执行此操作时,没有检测到任何东西.起初我以为我上传了错误的检查点,但是我进行了测试,并且相同的检查点可以离线处理这些图像,我不知道如何进一步调试.
When I do this, I get no detections. At first I thought I had uploaded the wrong checkpoint but I tested and the same checkpoint works with these images offline, I don't know how to debug further.
当我查看结果文件
prediction.results-00000-of-00001
prediction.results-00000-of-00001
只是空的
和文件
prediction.errors_stats-00000-of-00001
prediction.errors_stats-00000-of-00001
包含以下文本:(无法解码JSON对象",1)
contains the following text: ('No JSON object could be decoded', 1)
这是检测程序未运行但未检测到任何信号的标志,还是运行时出现问题?
Is this a sign the detection has run and detected nothing, or is there some problem while running?
也许是我准备的图像上传错误?
Maybe the problem is I am preparing the images wrong for uploading?
日志完全没有错误
谢谢
我正在做更多的测试,并尝试使用命令"gcloud ml-engine局部预测"而不是通常的局部代码在本地运行模型.我得到与在线相同的结果,根本没有答案,但是也没有错误消息
I was doing more tests and tried to run the model locally using the command "gcloud ml-engine local predict" instead of the usual local code. I get the same result as online, no answer at all, but also no error message
我正在使用TF_Record文件,所以我不理解JSON响应.这是我的命令的副本:
EDIT 2: I am using a TF_Record file, so I don't understand the JSON response. Here is a copy of my command:
gcloud ml-engine作业提交预测$ {JOB_ID} --data- 格式= tf_record \ --input-paths = gs://MY_BUCKET/data_dir/inputs.tfr \ --output-path = gs://MY_BUCKET/data_dir/version4 \ --region us-central1 \ --model ="gcp_detector" \ --version ="Version4"
gcloud ml-engine jobs submit prediction ${JOB_ID} --data- format=tf_record \ --input-paths=gs://MY_BUCKET/data_dir/inputs.tfr \ --output-path=gs://MY_BUCKET/data_dir/version4 \ --region us-central1 \ --model="gcp_detector" \ --version="Version4"
推荐答案
使用以下命令
模型导出:
# From tensorflow/models
export PYTHONPATH=$PYTHONPATH:/home/[user]/repos/DeepLearning/tools/models/research:/home/[user]/repos/DeepLearning/tools/models/research/slim
cd /home/[user]/repos/DeepLearning/tools/models/research
python object_detection/export_inference_graph.py \
--input_type encoded_image_string_tensor \
--pipeline_config_path /home/[user]/[path]/ssd_mobilenet_v1_pets.config \
--trained_checkpoint_prefix /[path_to_checkpoint]/model.ckpt-216593 \
--output_directory /[output_path]/output_inference_graph.pb
云执行
gcloud ml-engine jobs submit prediction ${JOB_ID} --data-format=TF_RECORD \
--input-paths=gs://my_inference/data_dir/inputs/* \
--output-path=${YOUR_OUTPUT_DIR} \
--region us-central1 \
--model="model_name" \
--version="version_name"
我不知道什么更改可以完全解决问题,但是有一些小的更改,例如tf_record现在是TF_RECORD.希望这可以帮助其他人.向Google支持人员寻求帮助的建议(他们提出了建议)
I don't know what change exactly fixes the issue, but there are some small changes like tf_record now being TF_RECORD. Hope this helps someone else. Props to google support for their help (they suggested the changes)
这篇关于Google Cloud ML使用对象检测模型返回空预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!