Azure Face API – Hands on using Python (basic)
Tags: azure, faceapi, python
Published: 2017-12-02 02:17:53

---
title: Azure Face API – Hands on using Python (basic)
published: true
description: Add recognition capabilities to your applications by detecting human faces in images using Python and Azure's Face API .
tags: Azure, FaceAPI, Python
---

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 .

![](https://notebooks.azure.com/Content/landing-page/pythonintro.png)

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) .

![](https://s3curi7y.tn/papers/image2.jpeg)

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 :

![](https://s3curi7y.tn/papers/image3.png)

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

![](https://s3curi7y.tn/papers/image4.png)

After that, click on 'create'

![](https://s3curi7y.tn/papers/image5.png)

And complete the form :

![](https://s3curi7y.tn/papers/image6.png)

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 :

![](https://s3curi7y.tn/papers/image7.png)

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

![](https://s3curi7y.tn/papers/image8.png)

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 .

![](https://s3curi7y.tn/papers/image9.png)

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 :

![](https://s3curi7y.tn/papers/image10.png)

And then, you can use the sample :

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

**Example :**

![](https://s3curi7y.tn/papers/image11.png)

**The hidden text is my access key .**

When you finish, something like this should appear :

![](https://s3curi7y.tn/papers/image12.png)

Detected faces should be in blue rectangles .