简体   繁体   English

Docker 上的 Google Cloud AutoML 预测

[英]Google Cloud AutoML prediction on Docker

I've trained a multi-class object detection model on Google Cloud AutoML.我已经在 Google Cloud AutoML 上训练了一个多类 object 检测 model。 I've dowloaded my own model from Container export.我已经从Container export 下载了我自己的 model。 Than I've deployed it on Docker with Google Cloud AutoML docker image.比我使用 Google Cloud AutoML docker 图像在 Docker 上部署它。 And I've send request with this code:我已经使用以下代码发送请求:

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()

I've successfully get the response from the docker as json format:我已经成功地从 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"
    }]
}

At this point, I want to know where is the detected bounding box in the image.此时,我想知道检测到的边界框在图像中的什么位置。 I know that I should get this information with detection_boxes , but I need to convert it to px values.我知道我应该使用detection_boxes获取此信息,但我需要将其转换为 px 值。 Because I'll process the bounding boxes again.因为我会再次处理边界框。

What is the pattern of the detection_boxes ? detection_boxes的模式是什么?

The format of detection_boxes is [min_y, min_x, max_y, max_x] , these values are normalized by the height and width of the image, so to get pixel coordinates y*height and x*width . detection_boxes 的格式为[min_y, min_x, max_y, max_x] ,这些值通过图像的高度和宽度进行归一化,从而得到像素坐标y*heightx*width

This is the same format as used by the Tensorflow Object Detection API, you can read about the format here这与 Tensorflow Object 检测 API 使用的格式相同,您可以在此处阅读有关格式的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Google Automl上进行预测 - Unable to make prediction on google automl 如何使用Google AutoML更改预测阈值? - How to change prediction threshold using Google AutoML? 错误:谷歌云 AutoML 无法导入库 - Error: google cloud AutoML cannot import library 如何使用谷歌云 AutoML 创建数据集 - How to create a dataset with google cloud AutoML 如何在Pandas DataFrame中操纵来自Google AutoML的预测响应? - How to manipulate prediction response from Google AutoML in a Pandas DataFrame? Google Cloud Vision AutoML 和 TensorFlow Object 检测差异 - Google Cloud Vision AutoML and TensorFlow Object Detection Differences 使用Google Cloud AutoML模型预测Firebase功能存储在Google Cloud存储中的图像 - Use Google Cloud AutoML model predict an image which is stored in Google Cloud storage in Firebase function 预处理数据以在Google Cloud中进行预测(Cloud Functions不支持Tensorflow) - Preprocess data for prediction in Google Cloud (Cloud Functions doesnt support Tensorflow) Cloud Run / Docker 加载大文件以进行 ML 预测 - Cloud Run / Docker loading large files for ML prediction 如何使用 anaconda 为 python 安装 google.cloud automl_v1beta1? - How to install google.cloud automl_v1beta1 for python using anaconda?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM