我正在尝试向 Azure ML Designer 端点(模型,我已部署)发出 POST 请求。这是我的代码:
import requests
scoring_uri = 'http:some-url/score'
key = 'someKey'
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = f'Bearer {key}'
response = requests.get('https://www.okino.ua/media/var/news/2019/12/04/Quentin_Tarantino.jpg')
input_data = "{\"data\": [" + str(response.content) + "]}"
resp = requests.post(scoring_uri, data=response.content, headers=headers)
print(resp.text)
我收到并错误:
{"error": {"code": 400, "message": "Input Data Error. Input data are inconsistent with schema.\nSchema: {'WebServiceInput0': {'columnAttributes': [{'name': 'image', 'type': 'Bytes', 'isFeature': True, 'elementType': {'typeName': 'bytes', 'isNullable': False}, 'properties': {'mime_type': 'image/png', 'image_ref': 'image_info'}}, {'name': 'id', 'type': 'Numeri\nData: b'\\xff\\xd8\\xff\\xe0\\x00\\x10JFIF\\x00\\x01\\x01\\x01\\x01,\\x01,\\x00\\x00\\xff\\xfe\\x00[Copyright Shutterstock 2019;82139424;3600;2400;1563865756;Tue, 23 Jul 2019 07:09:16 GMT;0\\xff\\xed\\x04\\x16Photoshop 3.0\\x008BIM\\x04\\x04\\x00\\x00\\x00\\x00\\x03\\xf9\\x1c\\x02\\x05\\x00\\n103\nTraceback (most recent call last):\n File \"/azureml-envs/azureml_c1330288c44b762b0282b6f129c5292f/lib/python3.6/site-packages/azureml/designer/serving/dagengine/processor.py\", line 18, in run\n webservice_input, global_parameters = self.pre_process(raw_data)\n File \"/azureml-envs/azureml_c1330288c44b762b0282b6f129c5292f/lib/python3.6/site-packages/azureml/designer/serving/dagengine/processor.py\", line 45, in pre_process\n json_data = json.loads(raw_data)\n File \"/azureml-envs/azureml_c1330288c44b762b0282b6f129c5292f/lib/python3.6/json/__init__.py\", line 349, in loads\n s = s.decode(detect_encoding(s), 'surrogatepass')\nUnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte\n", "details": ""}}
有人知道我应该如何将图像数据传递给 Azure ML 端点公开的数据吗?