Comment on page
Lab 3 - Deploy your model
In this lab we are going to deploy the model wrappend in an API in an Azure Container Instance and sending data to it with postman.
inference_folder = "./inference"
inference_script_url = "https://raw.githubusercontent.com/hnky/DevelopersGuideToAI/master/amls/resources/score.py"
inference_script_download_path = os.path.join(inference_folder,"score.py")
if not os.path.exists(inference_folder):
os.mkdir(inference_folder);
urllib.request.urlretrieve(inference_script_url, filename=inference_script_download_path)
inference_env = Environment(name="simpsons-inference")
conda_dep = CondaDependencies()
conda_dep.add_pip_package("azureml-defaults")
conda_dep.add_pip_package("torch")
conda_dep.add_pip_package("torchvision")
conda_dep.add_pip_package("pillow==5.4.1")
inference_env.python.conda_dependencies=conda_dep
inference_config = InferenceConfig(
entry_script="inference/score.py",
environment=inference_env
)
deploy_config = AciWebservice.deploy_configuration(
cpu_cores = model.resource_configuration.cpu,
memory_gb = model.resource_configuration.memory_in_gb,
description='Simpson Lego Classifier'
)
aci_service = Model.deploy(ws,
name="simpsons-pt-aci",
models = [model],
inference_config = inference_config,
deployment_config = deploy_config,
overwrite = True)
aci_service.wait_for_deployment(show_output=True)
print("Scoring endpoint:",aci_service.scoring_uri)
This step can take up to 10 minutesNote: if you don't see it immediately refresh the tab

Scoring URL
The easiest way to test your scoring endpoint is the code below.
image_uri = "https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Bart.jpg"
result = aci_service.run(input_data=json.dumps({ "url": image_uri}))
print(result)
- Get the scoring uriprint("Scoring endpoint:",aci_service.scoring_uri)
- Create a new request in Postman
- POST request
- Put scoring URL in call
- Send a raw body with the JSON below. Make sure JSON is selected in orange next to the raw radio button{ "url": "https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Bart.jpg"}

Scoring URL
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Krusty.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Bart.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Flanders.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Homer.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Lisa.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/marge.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Milhouse.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/MrBurns.jpg
https://raw.githubusercontent.com/hnky/dataset-lego-figures/master/_test/Wiggum.jpg
End