Serverless image classification with Azure Functions and Custom Vision – Part 3
In this article, you will create a Python Azure Function with HTTP trigger to consume a TensorFlow machine learning model.
Welcome to the fourth part of the learning series “Serverless image classification with Azure Functions and Custom Vision”! In the previous articles, you built an image classification model that predicts whether a photo contains a dog or a cat and used the exported TensorFlow model in an Azure Function.
To find out more about previous posts, check out the links below:
In this article, you will deploy your function project to Azure to create a serverless HTTP API for image classification. You will learn how to:
To complete the exercise, you will need:
Open your local function project in Visual Studio Code. Then, navigate to the Azure tab.
If you are not already signed in, under Resources, select Sign in to Azure.
After you’ve successfully signed in, select the + button in the Resources area to create a new Azure resource.
Then, select Create Function App in Azure.
Provide the following information when prompt:
Enter a globally unique name for the function app: Type a valid name. This name will be part of your function’s endpoint and must be unique.
Select a runtime stack: Choose the Python version on which you’ve created your local function project. If you followed the instructions in the previous article, select Python 3.9.
Select a location for new resources: Choose a region near you.
When the creation is complete, a notification is raised in Visual Studio Code.
Click on the Azure icon in the activity bar and under Workspace, select your local functions project.
Select the deploy button and then choose Deploy to Function App…
Choose the Function App you created in the previous step and then select Deploy.
Wait for the deployment to be complete. Once the deployment is complete, you will see the function’s endpoint in the Output.
Under Resources, expand your Function App projects, right-click on the classify
function and choose Execute Function Now…
In the request body enter { "img": "<URL>" }
, where <URL>
refers to the URL of an image.
If the function runs correctly, a notification is raised in Visual Studio Code containing information about the function’s execution.
https://classifycatsdogs.azurewebsites.net/api/classify?img=<URL>
.In this article, you learned how to deploy the Azure Functions project to Azure using Visual Studio Code.
If you are interested in learning more about Azure Functions, you may check out the following resources:
In this article, you will create a Python Azure Function with HTTP trigger to consume a TensorFlow machine learning model.
In this article, you will learn how to export a Custom Vision model programmatically using the Python client library.
In this article, you will learn how to export a Custom Vision model in TensorFlow format for use with Python apps.
This article will show you how to export your classifier using the Custom Vision SDK for Python and use the model to classify images.