Привет! Я успешно развернул модель обнаружения объектов на мл движке. Однако, когда я запрашиваю прогнозы, это дает мне следующую ошибку.
ERROR: (gcloud.ml-engine.predict) HTTP request failed. Response: {
"error": {
"code": 400,
"message": "Request payload size exceeds the limit: 1572864 bytes.",
"status": "INVALID_ARGUMENT"
}
}
Я использую следующую команду:
gcloud ml-engine predict --model fastercnn --version v4 --json-instances input.json
Мой input.json выглядит следующим образом:
{"inputs": {"b64": "/9j/4AAQSkZJRgABAQAAAQABAAD/..............}}
Примечание. Я усек кодировку long base 64
изображения для удобства чтения.
Определение моей модели:
MetaGraphDef с набором тегов: 'serve' содержит следующие SignatureDefs:
signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info:
dtype: DT_STRING
shape: (-1)
name: encoded_image_string_tensor:0
The given SavedModel SignatureDef contains the following output(s):
outputs['detection_boxes'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300, 4)
name: detection_boxes:0
outputs['detection_classes'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300)
name: detection_classes:0
outputs['detection_features'] tensor_info:
dtype: DT_FLOAT
shape: (-1, -1, -1, -1, -1)
name: detection_features:0
outputs['detection_multiclass_scores'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300, 2)
name: detection_multiclass_scores:0
outputs['detection_scores'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300)
name: detection_scores:0
outputs['num_detections'] tensor_info:
dtype: DT_FLOAT
shape: (-1)
name: num_detections:0
outputs['raw_detection_boxes'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300, 4)
name: raw_detection_boxes:0
outputs['raw_detection_scores'] tensor_info:
dtype: DT_FLOAT
shape: (-1, 300, 2)
name: raw_detection_scores:0
Method name is: tensorflow/serving/predict
Я попытался изменить размер моего изображения, используя следующий код, поэтомуон не превышает байтов, но все равно выдает мне ту же ошибку:
import base64
from PIL import Image
width = 256
height = 256
import json
import io
instances = []
with open('input.json', 'w') as f:
img = Image.open("test_image/hand1.jpg")
img = img.resize((width, height), Image.ANTIALIAS)
output_str = io.BytesIO()
img.save(output_str, "JPEG")
image_byte_array = output_str.getvalue()
image_base64 = base64.b64encode(image_byte_array).decode()
json_entry = {'image_bytes': {"b64": image_base64}}
request = json.dumps(json_entry)
f.write(request)
f.close()