How should I create a scoring script for object detection (pytorch) in Azure ML?
Hi there,
I have trained a PyTorch vision model on a local computer for object detection and want to deploy it on Azure ML. I have found a similar script for classification using pytorch where they are using the following scoring script. link: https://github.com/Azure/MachineLearningNotebooks/tree/master/how-to-use-azureml/ml-frameworks/pytorch/train-hyperparameter-tune-deploy-with-pytorch
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
import os
import torch
import torch.nn as nn
from torchvision import transforms
import json
from azureml.core.model import Model
def init():
global model
# AZUREML_MODEL_DIR is an environment variable created during deployment.
# It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)
# For multiple models, it points to the folder containing all deployed models (./azureml-models)
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model.pt')
model = torch.load(model_path, map_location=lambda storage, loc: storage)
model.eval()
def run(input_data):
input_data = torch.tensor(json.loads(input_data)['data'])
# get prediction
with torch.no_grad():
output = model(input_data)
classes = ['chicken', 'turkey']
softmax = nn.Softmax(dim=1)
pred_probs = softmax(output).numpy()[0]
index = torch.argmax(output, 1)
result = {"label": classes[index], "probability": str(pred_probs[index])}
return result
I have a few questions regarding this script. I am wondering what is 'input_data' in this case, is it an image in jpg format?
Also can my 'result' be in any dict format or it should have a specific format?
I have written a similar script for my purpose.
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license.
import os
import torch
import torchvision
#import torch.nn as nn
from torchvision import transforms
import json
import cv2
from azureml.core.model import Model
import numpy as np
from PIL import Image
import os
def init():
global model
# AZUREML_MODEL_DIR is an environment variable created during deployment.
# It is the path to the model folder (./azureml-models/$MODEL_NAME/$VERSION)
# For multiple models, it points to the folder containing all deployed models (./azureml-models)
# model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model.pt')
# model = torch.load(model_path, map_location=lambda storage, loc: storage)
# #model_path = Model.get_model_path(model_name='pytorch_external_model-test')
# model = torch.load(model_path)
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'),'model.pt')
model = torch.load(model_path, map_location=lambda storage, loc: storage)
#model = torch.load(model_path)
model.eval()
# the function takes the original prediction and the iou threshold.
def apply_nms(orig_prediction, iou_thresh=0.3):
# torchvision returns the indices of the bboxes to keep
keep = torchvision.ops.nms(orig_prediction['boxes'], orig_prediction['scores'], iou_thresh)
final_prediction = orig_prediction
#print(final_prediction['boxes'])
final_prediction['boxes'] = final_prediction['boxes'][keep].cpu() # had to add .cpu() after each tensor
final_prediction['scores'] = final_prediction['scores'][keep].cpu()
final_prediction['labels'] = final_prediction['labels'][keep].cpu()
return final_prediction
# def preprocess(input_data): # doesn't convert to tensor, while input for prediction needs to be in tensor
# img = cv2.imread(input_data)
# img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB).astype(np.float32)
# img_res = cv2.resize(img_rgb, (704, 480), cv2.INTER_AREA)
# # diving by 255
# img_res /= 255.0
# return img_res
def run(input_data):
img = Image.open(input_data).convert('RGB')
# set up transformation to resize the image
resize = transforms.Resize([704, 480])
img = resize(img)
to_tensor = transforms.ToTensor()
# apply transformation and convert to Pytorch tensor
tensor = to_tensor(img) # output shape [3, 704, 480]
#tensor = tensor.unsqueeze(0) # no need for [1, 3, 704, 480]
# link for converting image to tensor https://towardsdatascience.com/convert-images-to-tensors-in-pytorch-and-tensorflow-f0ab01383a03
#input_data = torch.tensor(json.loads(input_data)['data'])
#image = preprocess(input_data)
device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')
with torch.no_grad():
prediction = model([tensor.to(device)])[0]
nms_prediction = apply_nms(prediction, iou_thresh=0.3)
result = {"label": nms_prediction['labels'], "box": nms_prediction['boxes'], "score": nms_prediction['scores']}
return result
I followed this colab tutorial for training the object detection model. I am not using any transform to make the problem easy for now.
https://colab.research.google.com/drive/1NziO_b-SW9KmWFh-6C8to9H_QAdpmCBZ?usp=sharing#scrollTo=WOrNovPGh_k6
Model is deployed successfully. But getting this error
print(service.get_logs())
/bin/bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by /bin/bash)
/bin/bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by /bin/bash)
/bin/bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by /bin/bash)
/bin/bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by /bin/bash)
2022-06-15T00:14:38,162168400+00:00 - gunicorn/run
2022-06-15T00:14:38,166094000+00:00 - rsyslog/run
2022-06-15T00:14:38,171921600+00:00 - iot-server/run
bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by bash)
2022-06-15T00:14:38,190831400+00:00 | gunicorn/run |
2022-06-15T00:14:38,197941200+00:00 | gunicorn/run | ###############################################
2022-06-15T00:14:38,242881800+00:00 | gunicorn/run | AzureML Container Runtime Information
2022-06-15T00:14:38,300863500+00:00 | gunicorn/run | ###############################################
2022-06-15T00:14:38,351919200+00:00 - nginx/run
2022-06-15T00:14:38,377608200+00:00 | gunicorn/run |
2022-06-15T00:14:38,413561500+00:00 | gunicorn/run |
2022-06-15T00:14:38,436442300+00:00 | gunicorn/run | PATH environment variable: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/bin:/opt/miniconda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2022-06-15T00:14:38,472313100+00:00 | gunicorn/run | PYTHONPATH environment variable:
2022-06-15T00:14:38,478958600+00:00 | gunicorn/run |
2022-06-15T00:14:38,501877400+00:00 | gunicorn/run | Pip Dependencies (before dynamic installation)
EdgeHubConnectionString and IOTEDGE_IOTHUBHOSTNAME are not set. Exiting...
/bin/bash: /azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/libtinfo.so.5: no version information available (required by /bin/bash)
2022-06-15T00:14:38,787582000+00:00 - iot-server/finish 1 0
2022-06-15T00:14:38,793119200+00:00 - Exit code 1 is normal. Not restarting iot-server.
adal==1.2.7
albumentations==0.4.6
applicationinsights==0.11.10
argcomplete==2.0.0
attrs==21.4.0
azure-common==1.1.28
azure-core==1.22.1
azure-graphrbac==0.61.1
azure-identity==1.7.0
azure-mgmt-authorization==2.0.0
azure-mgmt-containerregistry==9.1.0
azure-mgmt-core==1.3.0
azure-mgmt-keyvault==9.3.0
azure-mgmt-resource==21.0.0
azure-mgmt-storage==20.0.0
azureml-core==1.42.0.post1
azureml-dataprep==4.0.3
azureml-dataprep-native==38.0.0
azureml-dataprep-rslex==2.6.3
azureml-dataset-runtime==1.42.0
azureml-defaults==1.42.0
azureml-inference-server-http==0.4.13
backports.tempfile==1.0
backports.weakref==1.0.post1
bcrypt==3.2.2
cachetools==4.2.4
certifi==2022.5.18.1
cffi==1.15.0
charset-normalizer==2.0.12
click==7.1.2
cloudpickle==2.1.0
configparser==3.7.4
contextlib2==21.6.0
contextvars==2.4
cryptography==36.0.2
cycler==0.11.0
dataclasses==0.8
decorator==4.4.2
distro==1.7.0
docker==5.0.3
dotnetcore2==3.1.23
Flask==1.0.3
fusepy==3.0.1
future==0.18.2
google-api-core==2.8.1
google-auth==2.8.0
googleapis-common-protos==1.56.2
gunicorn==20.1.0
humanfriendly==10.0
idna==3.3
imageio==2.15.0
imgaug==0.4.0
immutables==0.18
importlib-metadata==4.8.3
inference-schema==1.3.0
isodate==0.6.1
itsdangerous==1.1.0
jeepney==0.7.1
Jinja2==3.0.3
jmespath==0.10.0
json-logging-py==0.2
jsonpickle==2.2.0
jsonschema==3.2.0
kiwisolver==1.3.1
knack==0.9.0
MarkupSafe==2.0.1
matplotlib==3.3.4
msal==1.18.0
msal-extensions==0.3.1
msrest==0.6.21
msrestazure==0.6.4
ndg-httpsclient==0.5.1
networkx==2.5.1
numpy==1.19.5
oauthlib==3.2.0
opencensus==0.9.0
opencensus-context==0.1.2
opencensus-ext-azure==1.1.4
opencv-python==4.6.0.66
opencv-python-headless==4.6.0.66
packaging==21.3
paramiko==2.11.0
pathspec==0.9.0
Pillow==8.4.0
pkginfo==1.8.3
portalocker==2.4.0
protobuf==3.19.4
psutil==5.9.1
pyarrow==3.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycocotools==2.0.4
pycparser==2.21
Pygments==2.12.0
PyJWT==2.4.0
PyNaCl==1.5.0
pyOpenSSL==22.0.0
pyparsing==3.0.7
pyrsistent==0.18.0
PySocks==1.7.1
python-dateutil==2.8.2
pytz==2022.1
PyWavelets==1.1.1
PyYAML==6.0
requests==2.27.1
requests-oauthlib==1.3.1
rsa==4.8
scikit-image==0.17.2
scipy==1.5.4
SecretStorage==3.3.2
Shapely==1.8.2
six==1.16.0
tabulate==0.8.9
tifffile==2020.9.3
torch==1.10.1
torchvision==0.11.2
typing_extensions==4.1.1
urllib3==1.26.9
websocket-client==1.3.1
Werkzeug==1.0.1
wrapt==1.12.1
zipp==3.6.0
2022-06-15T00:14:40,561943700+00:00 | gunicorn/run |
2022-06-15T00:14:40,563774900+00:00 | gunicorn/run | ###############################################
2022-06-15T00:14:40,569936200+00:00 | gunicorn/run | AzureML Inference Server
2022-06-15T00:14:40,571682900+00:00 | gunicorn/run | ###############################################
2022-06-15T00:14:40,573373400+00:00 | gunicorn/run |
2022-06-15T00:14:40,580170100+00:00 | gunicorn/run |
2022-06-15T00:14:40,584523000+00:00 | gunicorn/run | Starting HTTP server
2022-06-15T00:14:40,590038900+00:00 | gunicorn/run |
Starting gunicorn 20.1.0
Listening at: http://127.0.0.1:31311 (77)
Using worker: sync
worker timeout is set to 300
Booting worker with pid: 125
SPARK_HOME not set. Skipping PySpark Initialization.
Initializing logger
2022-06-15 00:14:45,845 | root | INFO | Starting up app insights client
logging socket was found. logging is available.
logging socket was found. logging is available.
2022-06-15 00:14:45,846 | root | INFO | Starting up request id generator
2022-06-15 00:14:45,846 | root | INFO | Starting up app insight hooks
2022-06-15 00:14:45,847 | root | INFO | Invoking user's init function
2022-06-15 00:14:46,111 | root | INFO | Users's init has completed successfully
2022-06-15 00:14:46,115 | root | INFO | Skipping middleware: dbg_model_info as it's not enabled.
2022-06-15 00:14:46,116 | root | INFO | Skipping middleware: dbg_resource_usage as it's not enabled.
2022-06-15 00:14:46,121 | root | INFO | Scoring timeout is found from os.environ: 60000 ms
2022-06-15 00:14:49,997 | root | INFO | Swagger file not present
2022-06-15 00:14:49,998 | root | INFO | 404
127.0.0.1 - - [15/Jun/2022:00:14:49 +0000] "GET /swagger.json HTTP/1.0" 404 19 "-" "Go-http-client/1.1"
2022-06-15 00:14:54,621 | root | INFO | Swagger file not present
2022-06-15 00:14:54,622 | root | INFO | 404
127.0.0.1 - - [15/Jun/2022:00:14:54 +0000] "GET /swagger.json HTTP/1.0" 404 19 "-" "Go-http-client/1.1"
2022-06-15 00:14:54,974 | root | INFO | Scoring Timer is set to 60.0 seconds
2022-06-15 00:14:54,979 | root | ERROR | Encountered Exception: Traceback (most recent call last):
File "/var/azureml-server/routes.py", line 294, in run_scoring
response, time_taken_ms = invoke_user_with_timer(service_input, request_headers)
File "/var/azureml-server/routes.py", line 341, in invoke_user_with_timer
result, time_taken_ms = capture_time_taken(user_main.run)(**params)
File "/var/azureml-server/routes.py", line 322, in timer
result = func(*args, **kwargs)
File "/var/azureml-app/score2.py", line 57, in run
img = Image.open(input_data).convert('RGB')
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'test_img.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/azureml-server/routes.py", line 270, in score_realtime
service_input, request.headers, request.environ.get("REQUEST_ID", "00000000-0000-0000-0000-000000000000")
File "/var/azureml-server/routes.py", line 303, in run_scoring
raise RunFunctionException(str(exc))
run_function_exception.RunFunctionException
2022-06-15 00:14:54,979 | root | INFO | 500
127.0.0.1 - - [15/Jun/2022:00:14:54 +0000] "POST /score HTTP/1.0" 500 51 "-" "python-requests/2.26.0"
2022-06-15 00:14:54,988 | root | INFO | Scoring Timer is set to 60.0 seconds
2022-06-15 00:14:54,988 | root | ERROR | Encountered Exception: Traceback (most recent call last):
File "/var/azureml-server/routes.py", line 294, in run_scoring
response, time_taken_ms = invoke_user_with_timer(service_input, request_headers)
File "/var/azureml-server/routes.py", line 341, in invoke_user_with_timer
result, time_taken_ms = capture_time_taken(user_main.run)(**params)
File "/var/azureml-server/routes.py", line 322, in timer
result = func(*args, **kwargs)
File "/var/azureml-app/score2.py", line 57, in run
img = Image.open(input_data).convert('RGB')
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'test_img.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/azureml-server/routes.py", line 270, in score_realtime
service_input, request.headers, request.environ.get("REQUEST_ID", "00000000-0000-0000-0000-000000000000")
File "/var/azureml-server/routes.py", line 303, in run_scoring
raise RunFunctionException(str(exc))
run_function_exception.RunFunctionException
2022-06-15 00:14:54,988 | root | INFO | 500
127.0.0.1 - - [15/Jun/2022:00:14:54 +0000] "POST /score HTTP/1.0" 500 51 "-" "python-requests/2.26.0"
2022-06-15 00:14:56,004 | root | INFO | Scoring Timer is set to 60.0 seconds
2022-06-15 00:14:56,005 | root | ERROR | Encountered Exception: Traceback (most recent call last):
File "/var/azureml-server/routes.py", line 294, in run_scoring
response, time_taken_ms = invoke_user_with_timer(service_input, request_headers)
File "/var/azureml-server/routes.py", line 341, in invoke_user_with_timer
result, time_taken_ms = capture_time_taken(user_main.run)(**params)
File "/var/azureml-server/routes.py", line 322, in timer
result = func(*args, **kwargs)
File "/var/azureml-app/score2.py", line 57, in run
img = Image.open(input_data).convert('RGB')
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'test_img.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/azureml-server/routes.py", line 270, in score_realtime
service_input, request.headers, request.environ.get("REQUEST_ID", "00000000-0000-0000-0000-000000000000")
File "/var/azureml-server/routes.py", line 303, in run_scoring
raise RunFunctionException(str(exc))
run_function_exception.RunFunctionException
2022-06-15 00:14:56,005 | root | INFO | 500
127.0.0.1 - - [15/Jun/2022:00:14:56 +0000] "POST /score HTTP/1.0" 500 51 "-" "python-requests/2.26.0"
2022-06-15 00:14:58,028 | root | INFO | Scoring Timer is set to 60.0 seconds
2022-06-15 00:14:58,029 | root | ERROR | Encountered Exception: Traceback (most recent call last):
File "/var/azureml-server/routes.py", line 294, in run_scoring
response, time_taken_ms = invoke_user_with_timer(service_input, request_headers)
File "/var/azureml-server/routes.py", line 341, in invoke_user_with_timer
result, time_taken_ms = capture_time_taken(user_main.run)(**params)
File "/var/azureml-server/routes.py", line 322, in timer
result = func(*args, **kwargs)
File "/var/azureml-app/score2.py", line 57, in run
img = Image.open(input_data).convert('RGB')
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/PIL/Image.py", line 2975, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'test_img.jpg'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1832, in full_dispatch_request
rv = self.dispatch_request()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/flask/app.py", line 1818, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/var/azureml-server/routes.py", line 270, in score_realtime
service_input, request.headers, request.environ.get("REQUEST_ID", "00000000-0000-0000-0000-000000000000")
File "/var/azureml-server/routes.py", line 303, in run_scoring
raise RunFunctionException(str(exc))
run_function_exception.RunFunctionException
2022-06-15 00:14:58,030 | root | INFO | 500
127.0.0.1 - - [15/Jun/2022:00:14:58 +0000] "POST /score HTTP/1.0" 500 51 "-" "python-requests/2.26.0"
Exception in worker process
Traceback (most recent call last):
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
worker.init_process()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/gunicorn/workers/base.py", line 142, in init_process
self.run()
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 125, in run
self.run_for_one(timeout)
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 84, in run_for_one
self.wait(timeout)
File "/azureml-envs/azureml_8003354dcfcc0ac94ef7d92e5607092f/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 36, in wait
ret = select.select(self.wait_fds, [], [], timeout)
File "/var/azureml-server/routes.py", line 159, in alarm_handler
raise TimeoutException(error_message)
timeout_exception.TimeoutException
Worker exiting (pid: 125)
worker timeout is set to 300
Booting worker with pid: 157
SPARK_HOME not set. Skipping PySpark Initialization.
Initializing logger
2022-06-15 00:16:03,376 | root | INFO | Starting up app insights client
logging socket was found. logging is available.
logging socket was found. logging is available.
2022-06-15 00:16:03,376 | root | INFO | Starting up request id generator
2022-06-15 00:16:03,377 | root | INFO | Starting up app insight hooks
2022-06-15 00:16:03,377 | root | INFO | Invoking user's init function
2022-06-15 00:16:03,624 | root | INFO | Users's init has completed successfully
2022-06-15 00:16:03,626 | root | INFO | Skipping middleware: dbg_model_info as it's not enabled.
2022-06-15 00:16:03,626 | root | INFO | Skipping middleware: dbg_resource_usage as it's not enabled.
2022-06-15 00:16:03,633 | root | INFO | Scoring timeout is found from os.environ: 60000 ms
127.0.0.1 - - [15/Jun/2022:00:20:12 +0000] "POST / HTTP/1.0" 405 178 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
127.0.0.1 - - [15/Jun/2022:00:20:13 +0000] "GET /.env HTTP/1.0" 404 232 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36"
2022-06-15 00:35:48,752 | root | INFO | Swagger file not present
2022-06-15 00:35:48,753 | root | INFO | 404
127.0.0.1 - - [15/Jun/2022:00:35:48 +0000] "GET /swagger.json HTTP/1.0" 404 19 "-" "Go-http-client/1.1"
result = service.run(input_data="test_img.jpg")
print(result)
Received bad response from service. More information can be found by calling `.get_logs()` on the webservice object.
Response Code: 502
Headers: {'Connection': 'keep-alive', 'Content-Length': '51', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Wed, 15 Jun 2022 00:50:21 GMT', 'Server': 'nginx/1.14.0 (Ubuntu)', 'X-Ms-Request-Id': 'dacf03b8-adb6-4cbf-8cea-d0c4086712f4', 'X-Ms-Run-Function-Failed': 'True'}
Content: b"[Errno 2] No such file or directory: 'test_img.jpg'"
---------------------------------------------------------------------------
WebserviceException Traceback (most recent call last)
<ipython-input-18-c76911546a4f> in <module>
----> 1 result = service.run(input_data="test_img.jpg")
2 print(result)
/anaconda/envs/azureml_py36/lib/python3.6/site-packages/azureml/core/webservice/aci.py in run(self, input_data)
403 'Headers: {}\n'
404 'Content: {}'.format(resp.status_code, resp.headers, resp.content),
--> 405 logger=module_logger)
406
407 def update(self, image=None, tags=None, properties=None, description=None, auth_enabled=None, ssl_enabled=None,
WebserviceException: WebserviceException:
Message: Received bad response from service. More information can be found by calling `.get_logs()` on the webservice object.
Response Code: 502
Headers: {'Connection': 'keep-alive', 'Content-Length': '51', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Wed, 15 Jun 2022 00:50:21 GMT', 'Server': 'nginx/1.14.0 (Ubuntu)', 'X-Ms-Request-Id': 'dacf03b8-adb6-4cbf-8cea-d0c4086712f4', 'X-Ms-Run-Function-Failed': 'True'}
Content: b"[Errno 2] No such file or directory: 'test_img.jpg'"
InnerException None
ErrorResponse
{
"error": {
"message": "Received bad response from service. More information can be found by calling `.get_logs()` on the webservice object.\nResponse Code: 502\nHeaders: {'Connection': 'keep-alive', 'Content-Length': '51', 'Content-Type': 'text/html; charset=utf-8', 'Date': 'Wed, 15 Jun 2022 00:50:21 GMT', 'Server': 'nginx/1.14.0 (Ubuntu)', 'X-Ms-Request-Id': 'dacf03b8-adb6-4cbf-8cea-d0c4086712f4', 'X-Ms-Run-Function-Failed': 'True'}\nContent: b\"[Errno 2] No such file or directory: 'test_img.jpg'\""
}
}
What kind of response is needed? I have test_img.jpg file in the same directory.
Any help is appreciated.
Thank you.