DEV Community

Muhammad Habib Jawady
Muhammad Habib Jawady

Posted on

Azure Face API – Hands on using Python (basic)

Howdy everybody !

This is Muhammad Habib in a new hands-on tutorial. In this article, I will be working on  Azure 's Face recognition API . I will be showing you how to exploit this very powerful API in order to add recognition capabilities to your applications by detecting human faces in images .

This will be a guide with no prequisite skills, although the only requirements are the access to the Azure portal and basic knowledge related to web frameworks or JS syntax as we will be building our demo project using Angular or Python if you're reading the basic version .

What is Azure ?

Microsoft Azure is a scalable cloud computig platform launched by Microsoft on February 2010. Due to its simplicity and the veriety of services it provides, developers choose it to deploy their projects and its APIs to make things easier. Guided by a huge set of articles and proprietor documentation, Azure became one of the kings in the kingdom of Cloud, coming the second just after AWS (Amazon Web Services) .

What is Azure 's FaceAPI ?

Azure's Face API is an Application Programming Interface, provided within the Azure Portal . It is used to detect human faces and compare similar ones and identify people in order to classify them in groups .

Getting our API keys :

In order to access any API, it is required that you provide an access token/key as a parameter in every request to the endpoint. Getting your FaceAPI key requires that you have access to an Azure account with permitted access to the service .

After logging in, visit the dashboard :

Then click on the big green + sign on the left top corner , and search for face API :

After that, click on 'create'

And complete the form :

After that you will automatically be redirected to the dashboard and the creation should be successful . Visit the service for the first time and something like this should appear :

Click on keys, and copy them to a safe place .

P.S : In case you accidentally showed them to an untrusted party you can safely regenerate them changing by that the status of previous keys to unvalid .

Next, visit the overview page, and copy the endpoint URL, this should varie between regions .

First USAGE:

Now you should be ready to use the sample code in :

https://github.com/hbibz-deploy/AzureCognitive-py/

Copy/clone the script called 'FaceAPI.py' and save it .

Before running you code, and assuming that you have both 3.X python and pip installed , run :

And then, you can use the sample :

Command : python FaceAPI.py {key} {Image URL}

Example :

The hidden text is my access key .

When you finish, something like this should appear :

Detected faces should be in blue rectangles .

Oldest comments (0)