Azure Face client library for Python Samples
These are code samples that show common scenario operations with the Azure Face client library.
The async versions of the samples (the python sample files appended with _async) show asynchronous operations.
Several Azure Face Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Face:
sample_authentication.py (async version) - Examples for authenticating and creating the client:
- From a key
- From Microsoft Entra ID
sample_face_liveness_detection.py (async version) - Examples for performing liveness detection
sample_face_liveness_detection_with_verification.py (async version) - Examples for performing liveness detection with face verification
sample_face_detection.py (async version) - Examples for detecting human faces in an image:
- From a binary data
- From a URL
sample_stateless_face_verification.py (async version) - Examples for verifying whether two faces belong to the same person.
sample_face_grouping.py (async version) - Examples for dividing candidate faces into groups based on face similarity.
sample_find_similar_faces.py (async version) - Examples for searching the similar-looking faces from a set of candidate faces:
- From a faceId array
- From a large face list
sample_verify_and_identify_from_large_person_group.py (async version) - Examples for verifying and identifying faces from a large person group.
Prerequisites
- Python 3.8 or later is required to use this package
- You must have an Azure subscription and an Face APIs account to run these samples.
Setup
- Install the Face client library for Python with pip:
pip install azure-ai-vision-face
- Clone or download this sample repository
- Open the sample folder in Visual Studio Code or your IDE of choice.
Running the samples
- Open a terminal window and
cdto the directory that the samples are saved in. - Set the environment variables specified in the sample file you wish to run.
- Follow the usage described in the file, e.g.
python sample_face_detection.py
Next steps
Check out the API reference documentation to learn more about what you can do with the Azure Face client library.