Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
167 lines (127 sloc) 4.61 KB

Face Recognition Service

This MLHub package provides a quick introduction to the pre-built Face models provided through the face API of Microsoft Azure's Cognitive Services.

A free Azure subscription allowing up to 5,000 transactions per month is available from https://azure.microsoft.com/free/. Once set up visit https://ms.portal.azure.com and Create a resource under AI and Machine Learning called Face. Once created you can access the web API subscription key from the portal. This will be prompted for in the demo.

Please note that this is closed source software which limits your freedoms and has no guarantee of ongoing availability.

Visit the github repository for more details: https://github.com/gjwgit/azface

The Python code is based on the Microsoft Azure Face API Documentation.

Usage

  • To install mlhub (e.g., Ubuntu 18.04 LTS)

    $ pip3 install mlhub
  • To install and configure the pre-built model:

    $ ml install azface
    $ ml configure azface

Demonstration

$ ml demo azface
=============
Face Services
=============

Welcome to a demo of the pre-built models for Face provided through Azure's 
Cognitive Services. This cloud service accepts images and can perform 
various analyses of the images, returning the results locally.

An Azure resource is required to access this service (and to run this
demo). See the README for details of a free subscription. Then you can
provide the key and the endpoint information here.

Please paste your Face API subscription key []: ********************************
Please paste your endpoint []: https://australiaeast.api.cognitive.microsoft.com/face/v1.0

The Azure Face API subscription key and endpoint have been saved to:

  /home/gjw/.mlhub/azface/key.txt

Detecting faces in photo:
  photo/detection/detection2.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in photo:
  photo/detection/detection3.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in photo:
  photo/detection/detection6.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in photo:
  photo/detection/detection1.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in photo:
  photo/detection/detection5.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in photo:
  photo/detection/detection4.jpg
Please close each image window (Ctrl-w) to proceed.

Detecting faces in the target photo:
  photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg

Detecting faces in the candidate photo:
  photo/identification/identification1.jpg

Matching the face No. 0 ...

Please close each image window (Ctrl-w) to proceed.

To detect faces in provided photos:

  $ ml detect azface

Commands

  • To detect faces in a photo:

    $ ml detect azface

    It will ask for your Azure face API key, endpoint, as well as a URL or path of a photo to detect faces. You also can provide these by command line options:

    $ ml detect azface --key 'xxx' --endpoint 'https://yyy' --photo '~/.mlhub/azface/photo/detection'

    Key and endpoint can also be stored in a file such as key.txt:

    key = 'xxx'
    endpoint = 'https://yyy'
    

    And they can be read by:

    $ ml detect azface --key-file key.txt --photo '~/.mlhub/azface/photo/detection'
  • To find similar faces between two photos:

    $ ml similar azface --target xxx.jpg --candidate yyy.jpg --key-file zzz.txt

    Thus all faces in yyy.jpg that are similar to the faces in xxx.jpg will be found.

    Examples:

    $ ml similar azface --target '~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg' --candidate '~/.mlhub/azface/photo/identification/identification1.jpg'
    $ ml similar azface --target '~/.mlhub/azface/photo/identification/identification1.jpg' --candidate '~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/'

Reference

You can’t perform that action at this time.