【发布时间】:2020-07-17 00:26:56
【问题描述】:
我已经在 Google Cloud AutoML 上训练了一个多类对象检测模型。我已经从 Container 导出中下载了我自己的模型。比我使用 Google Cloud AutoML docker 映像将它部署在 Docker 上。我已经使用此代码发送请求:
import base64
import io
import json
import requests
def process(image_file_path, image_key="1", port_number=8501):
with io.open(image_file_path, 'rb') as image_file:
encoded_image = base64.b64encode(image_file.read()).decode('utf-8')
instances = {
"instances": [
{
"image_bytes": {
"b64": str(encoded_image)
},
"key": image_key
}
]
}
url = 'http://localhost:{}/v1/models/default:predict'.format(port_number)
response = requests.post(url, data=json.dumps(instances))
return response.json()
我已经成功地从 docker 获得了 json 格式的响应:
{
"predictions": [{
"detection_multiclass_scores": [
[0.00540795922, 0.99754715],
...
],
"detection_classes": [1.0, ...],
"num_detections": 40.0,
"image_info": [320, 320, 1, 0, 320, 320],
"detection_boxes": [
[0.0382162929, 0.0984618068, 0.746192276, 0.991413414],
...
],
"detection_scores": [0.99754715, ...],
"detection_classes_as_text": ["image_class", ...],
"key": "1"
}]
}
此时,我想知道检测到的边界框在图像中的哪个位置。我知道我应该使用detection_boxes 获取此信息,但我需要将其转换为 px 值。因为我会再次处理边界框。
detection_boxes 的模式是什么?
【问题讨论】:
-
它是 %。如果您的图像宽度为 1280,则数字 ex:
1280*0.0382162929 -
我知道。我在问像 x1,y1,x2,y2 这样的模式是什么
标签: python docker tensorflow object-detection google-cloud-automl