azure.cognitiveservices.vision.face.operations module

class azure.cognitiveservices.vision.face.operations.FaceListOperations(client, config, serializer, deserializer)[source]

Bases: object

FaceListOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

add_face_from_stream(face_list_id, image, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, callback=None, **operation_config)[source]

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](https://docs.microsoft.com/rest/api/faceapi/facelist/deleteface) or [FaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/facelist/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better detection and recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • image (Generator) – An image stream.

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • callback (Callable[Bytes, response=None]) – When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None.

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

add_face_from_url(face_list_id, url, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, **operation_config)[source]

Add a face to a specified face list, up to 1,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [FaceList - Delete Face](https://docs.microsoft.com/rest/api/faceapi/facelist/deleteface) or [FaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/facelist/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better detection and recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • url (str) – Publicly reachable URL of an image

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

create(face_list_id, name, user_data=None, recognition_model='recognition_01', custom_headers=None, raw=False, **operation_config)[source]

Create an empty face list with user-specified faceListId, name, an optional userData and recognitionModel. Up to 64 face lists are allowed in one subscription. <br /> Face list is a list of faces, up to 1,000 faces, and used by [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). <br /> After creation, user should use [FaceList - Add Face](https://docs.microsoft.com/rest/api/faceapi/facelist/addfacefromurl) to import the faces. No image will be stored. Only the extracted face features are stored on server until [FaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/facelist/delete) is called. <br /> Find Similar is used for scenario like finding celebrity-like faces, similar face filtering, or as a light way face identification. But if the actual use is to identify person, please use [PersonGroup](https://docs.microsoft.com/rest/api/faceapi/persongroup) / [LargePersonGroup](https://docs.microsoft.com/rest/api/faceapi/largepersongroup) and [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify). <br /> Please consider [LargeFaceList](https://docs.microsoft.com/rest/api/faceapi/largefacelist) when the face number is large. It can support up to 1,000,000 faces. <br />’recognitionModel’ should be specified to associate with this face list. The default value for ‘recognitionModel’ is ‘recognition_01’, if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing face list will use the recognition model that’s already associated with the collection. Existing face features in a face list can’t be updated to features extracted by another version of recognition model. Please Refer to [Specify a face recognition model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model).

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • recognition_model (str or RecognitionModel) – Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete(face_list_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a specified face list.

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete_face(face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a face from a face list by specified faceListId and persistedFaceId. <br /> Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel.

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(face_list_id, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

Retrieve a face list’s faceListId, name, userData, recognitionModel and faces in the face list. .

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

FaceList or ClientRawResponse if raw=true

Return type

FaceList or ClientRawResponse

Raises

APIErrorException

list(return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

List face lists’ faceListId, name, userData and recognitionModel. <br /> To get face information inside faceList use [FaceList - Get](https://docs.microsoft.com/rest/api/faceapi/facelist/get) .

Parameters
  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[FaceList] or ClientRawResponse

Raises

APIErrorException

update(face_list_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update information of a face list.

Parameters
  • face_list_id (str) – Id referencing a particular face list.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.FaceOperations(client, config, serializer, deserializer)[source]

Bases: object

FaceOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

detect_with_stream(image, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, recognition_model='recognition_01', return_recognition_model=False, detection_model='detection_01', face_id_time_to_live=86400, custom_headers=None, raw=False, callback=None, **operation_config)[source]

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.<br /> * No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face - Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface), and [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call. * Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * For optimal results when querying [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face - Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface), and [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar) (‘returnFaceId’ is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes). * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) * Different ‘recognitionModel’ values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with ‘recognitionModel’ parameter. The default value for ‘recognitionModel’ is ‘recognition_01’, if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to [Specify a recognition model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model).

Parameters
  • image (Generator) – An image stream.

  • return_face_id (bool) – A value indicating whether the operation should return faceIds of detected faces.

  • return_face_landmarks (bool) – A value indicating whether the operation should return landmarks of the detected faces.

  • return_face_attributes (list[str or FaceAttributeType]) – Analyze and return the one or more specified face attributes in the comma-separated string like “returnFaceAttributes=age,gender”. The available attributes depends on the ‘detectionModel’ specified. ‘detection_01’ supports age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, and qualityForRecognition. While ‘detection_02’ does not support any attributes and ‘detection_03’ only supports mask and qualityForRecognition. Additionally, qualityForRecognition is only supported when the ‘recognitionModel’ is specified as ‘recognition_03’ or ‘recognition_04’. Note that each face attribute analysis has additional computational and time cost.

  • recognition_model (str or RecognitionModel) – Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds, (Large)FaceList or (Large)PersonGroup. A recognition model name can be provided when performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup - Create. The default value is ‘recognition_01’, if latest model needed, please explicitly specify the model you need. Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • face_id_time_to_live (int) – The number of seconds for the faceId being cached. Supported range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours).

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • callback (Callable[Bytes, response=None]) – When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None.

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[DetectedFace] or ClientRawResponse

Raises

APIErrorException

detect_with_url(url, return_face_id=True, return_face_landmarks=False, return_face_attributes=None, recognition_model='recognition_01', return_recognition_model=False, detection_model='detection_01', face_id_time_to_live=86400, custom_headers=None, raw=False, **operation_config)[source]

Detect human faces in an image, return face rectangles, and optionally with faceIds, landmarks, and attributes.<br /> * No image will be stored. Only the extracted face feature will be stored on server. The faceId is an identifier of the face feature and will be used in [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face - Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface), and [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). The stored face feature(s) will expire and be deleted at the time specified by faceIdTimeToLive after the original detection call. * Optional parameters include faceId, landmarks, and attributes. Attributes include age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, mask, and qualityForRecognition. Some of the results returned for specific attributes may not be highly accurate. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * Up to 100 faces can be returned for an image. Faces are ranked by face rectangle size from large to small. * For optimal results when querying [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify), [Face - Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface), and [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar) (‘returnFaceId’ is true), please use faces that are: frontal, clear, and with a minimum size of 200x200 pixels (100 pixels between eyes). * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model). * Different ‘recognitionModel’ values are provided. If follow-up operations like Verify, Identify, Find Similar are needed, please specify the recognition model with ‘recognitionModel’ parameter. The default value for ‘recognitionModel’ is ‘recognition_01’, if latest model needed, please explicitly specify the model you need in this parameter. Once specified, the detected faceIds will be associated with the specified recognition model. More details, please refer to [Specify a recognition model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model).

Parameters
  • url (str) – Publicly reachable URL of an image

  • return_face_id (bool) – A value indicating whether the operation should return faceIds of detected faces.

  • return_face_landmarks (bool) – A value indicating whether the operation should return landmarks of the detected faces.

  • return_face_attributes (list[str or FaceAttributeType]) – Analyze and return the one or more specified face attributes in the comma-separated string like “returnFaceAttributes=age,gender”. The available attributes depends on the ‘detectionModel’ specified. ‘detection_01’ supports age, gender, headPose, smile, facialHair, glasses, emotion, hair, makeup, occlusion, accessories, blur, exposure, noise, and qualityForRecognition. While ‘detection_02’ does not support any attributes and ‘detection_03’ only supports mask and qualityForRecognition. Additionally, qualityForRecognition is only supported when the ‘recognitionModel’ is specified as ‘recognition_03’ or ‘recognition_04’. Note that each face attribute analysis has additional computational and time cost.

  • recognition_model (str or RecognitionModel) – Name of recognition model. Recognition model is used when the face features are extracted and associated with detected faceIds, (Large)FaceList or (Large)PersonGroup. A recognition model name can be provided when performing Face - Detect or (Large)FaceList - Create or (Large)PersonGroup - Create. The default value is ‘recognition_01’, if latest model needed, please explicitly specify the model you need. Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • face_id_time_to_live (int) – The number of seconds for the faceId being cached. Supported range from 60 seconds up to 86400 seconds. The default value is 86400 (24 hours).

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[DetectedFace] or ClientRawResponse

Raises

APIErrorException

find_similar(face_id, face_list_id=None, large_face_list_id=None, face_ids=None, max_num_of_candidates_returned=20, mode='matchPerson', custom_headers=None, raw=False, **operation_config)[source]

Given query face’s faceId, to search the similar-looking faces from a faceId array, a face list or a large face list. faceId array contains the faces created by [Face - Detect With Url](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl) or [Face - Detect With Stream](https://docs.microsoft.com/rest/api/faceapi/face/detectwithstream), which will expire at the time specified by faceIdTimeToLive after creation. A “faceListId” is created by [FaceList - Create](https://docs.microsoft.com/rest/api/faceapi/facelist/create) containing persistedFaceIds that will not expire. And a “largeFaceListId” is created by [LargeFaceList - Create](https://docs.microsoft.com/rest/api/faceapi/largefacelist/create) containing persistedFaceIds that will also not expire. Depending on the input the returned similar faces list contains faceIds or persistedFaceIds ranked by similarity. <br/>Find similar has two working modes, “matchPerson” and “matchFace”. “matchPerson” is the default mode that it tries to find faces of the same person as possible by using internal same-person thresholds. It is useful to find a known person’s other photos. Note that an empty list will be returned if no faces pass the internal thresholds. “matchFace” mode ignores same-person thresholds and returns ranked similar faces anyway, even the similarity is low. It can be used in the cases like searching celebrity-looking faces. <br/>The ‘recognitionModel’ associated with the query face’s faceId should be the same as the ‘recognitionModel’ used by the target faceId array, face list or large face list. .

Parameters
  • face_id (str) – FaceId of the query face. User needs to call Face - Detect first to get a valid faceId. Note that this faceId is not persisted and will expire at the time specified by faceIdTimeToLive after the detection call

  • face_list_id (str) – An existing user-specified unique candidate face list, created in Face List - Create a Face List. Face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

  • large_face_list_id (str) – An existing user-specified unique candidate large face list, created in LargeFaceList - Create. Large face list contains a set of persistedFaceIds which are persisted and will never expire. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

  • face_ids (list[str]) – An array of candidate faceIds. All of them are created by Face - Detect and the faceIds will expire at the time specified by faceIdTimeToLive after the detection call. The number of faceIds is limited to 1000. Parameter faceListId, largeFaceListId and faceIds should not be provided at the same time.

  • max_num_of_candidates_returned (int) – The number of top similar faces returned. The valid range is [1, 1000].

  • mode (str or FindSimilarMatchMode) – Similar face searching mode. It can be “matchPerson” or “matchFace”. Possible values include: ‘matchPerson’, ‘matchFace’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[SimilarFace] or ClientRawResponse

Raises

APIErrorException

group(face_ids, custom_headers=None, raw=False, **operation_config)[source]

Divide candidate faces into groups based on face similarity.<br /> * The output is one or more disjointed face groups and a messyGroup. A face group contains faces that have similar looking, often of the same person. Face groups are ranked by group size, i.e. number of faces. Notice that faces belonging to a same person might be split into several groups in the result. * MessyGroup is a special face group containing faces that cannot find any similar counterpart face from original faces. The messyGroup will not appear in the result if all faces found their counterparts. * Group API needs at least 2 candidate faces and 1000 at most. We suggest to try [Face - Verify](https://docs.microsoft.com/rest/api/faceapi/face/verifyfacetoface) when you only have 2 candidate faces. * The ‘recognitionModel’ associated with the query faces’ faceIds should be the same. .

Parameters
  • face_ids (list[str]) – Array of candidate faceId created by Face - Detect. The maximum is 1000 faces

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

GroupResult or ClientRawResponse if raw=true

Return type

GroupResult or ClientRawResponse

Raises

APIErrorException

identify(face_ids, person_group_id=None, large_person_group_id=None, max_num_of_candidates_returned=1, confidence_threshold=None, custom_headers=None, raw=False, **operation_config)[source]

1-to-many identification to find the closest matches of the specific query person face from a person group or large person group. <br/> For each face in the faceIds array, Face Identify will compute similarities between the query face and all the faces in the person group (given by personGroupId) or large person group (given by largePersonGroupId), and return candidate person(s) for that face ranked by similarity confidence. The person group/large person group should be trained to make it ready for identification. See more in [PersonGroup - Train](https://docs.microsoft.com/rest/api/faceapi/persongroup/train) and [LargePersonGroup - Train](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/train). <br/> Remarks:<br /> * The algorithm allows more than one face to be identified independently at the same request, but no more than 10 faces. * Each person in the person group/large person group could have more than one face, but no more than 248 faces. * Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Number of candidates returned is restricted by maxNumOfCandidatesReturned and confidenceThreshold. If no person is identified, the returned candidates will be an empty array. * Try [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar) when you need to find similar faces from a face list/large face list instead of a person group/large person group. * The ‘recognitionModel’ associated with the query faces’ faceIds should be the same as the ‘recognitionModel’ used by the target person group or large person group. .

Parameters
  • face_ids (list[str]) – Array of query faces faceIds, created by the Face - Detect. Each of the faces are identified independently. The valid number of faceIds is between [1, 10].

  • person_group_id (str) – PersonGroupId of the target person group, created by PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time.

  • large_person_group_id (str) – LargePersonGroupId of the target large person group, created by LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time.

  • max_num_of_candidates_returned (int) – The range of maxNumOfCandidatesReturned is between 1 and 100 (default is 1).

  • confidence_threshold (float) – Confidence threshold of identification, used to judge whether one face belong to one person. The range of confidenceThreshold is [0, 1] (default specified by algorithm).

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[IdentifyResult] or ClientRawResponse

Raises

APIErrorException

verify_face_to_face(face_id1, face_id2, custom_headers=None, raw=False, **operation_config)[source]

Verify whether two faces belong to a same person or whether one face belongs to a person. <br/> Remarks:<br /> * Higher face image quality means better identification precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * For the scenarios that are sensitive to accuracy please make your own judgment. * The ‘recognitionModel’ associated with the query faces’ faceIds should be the same as the ‘recognitionModel’ used by the target face, person group or large person group. .

Parameters
  • face_id1 (str) – FaceId of the first face, comes from Face - Detect

  • face_id2 (str) – FaceId of the second face, comes from Face - Detect

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

VerifyResult or ClientRawResponse if raw=true

Return type

VerifyResult or ClientRawResponse

Raises

APIErrorException

verify_face_to_person(face_id, person_id, person_group_id=None, large_person_group_id=None, custom_headers=None, raw=False, **operation_config)[source]

Verify whether two faces belong to a same person. Compares a face Id with a Person Id.

Parameters
  • face_id (str) – FaceId of the face, comes from Face - Detect

  • person_id (str) – Specify a certain person in a person group or a large person group. personId is created in PersonGroup Person - Create or LargePersonGroup Person - Create.

  • person_group_id (str) – Using existing personGroupId and personId for fast loading a specified person. personGroupId is created in PersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time.

  • large_person_group_id (str) – Using existing largePersonGroupId and personId for fast loading a specified person. largePersonGroupId is created in LargePersonGroup - Create. Parameter personGroupId and largePersonGroupId should not be provided at the same time.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

VerifyResult or ClientRawResponse if raw=true

Return type

VerifyResult or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.LargeFaceListOperations(client, config, serializer, deserializer)[source]

Bases: object

LargeFaceListOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

add_face_from_stream(large_face_list_id, image, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, callback=None, **operation_config)[source]

Add a face to a specified large face list, up to 1,000,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargeFaceList Face - Delete](https://docs.microsoft.com/rest/api/faceapi/largefacelist/deleteface) or [LargeFaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/largefacelist/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model). Quota: * Free-tier subscription quota: 1,000 faces per large face list. * S0-tier subscription quota: 1,000,000 faces per large face list.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • image (Generator) – An image stream.

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • callback (Callable[Bytes, response=None]) – When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None.

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

add_face_from_url(large_face_list_id, url, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, **operation_config)[source]

Add a face to a specified large face list, up to 1,000,000 faces. <br /> To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargeFaceList Face - Delete](https://docs.microsoft.com/rest/api/faceapi/largefacelist/deleteface) or [LargeFaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/largefacelist/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same face list are processed sequentially and to/from different face lists are in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) Quota: * Free-tier subscription quota: 1,000 faces per large face list. * S0-tier subscription quota: 1,000,000 faces per large face list.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • url (str) – Publicly reachable URL of an image

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

create(large_face_list_id, name, user_data=None, recognition_model='recognition_01', custom_headers=None, raw=False, **operation_config)[source]

Create an empty large face list with user-specified largeFaceListId, name, an optional userData and recognitionModel. <br /> Large face list is a list of faces, up to 1,000,000 faces, and used by [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). <br /> After creation, user should use [LargeFaceList Face - Add](https://docs.microsoft.com/rest/api/faceapi/largefacelist/addfacefromurl) to import the faces and [LargeFaceList - Train](https://docs.microsoft.com/rest/api/faceapi/largefacelist/train) to make it ready for [Face - Find Similar](https://docs.microsoft.com/rest/api/faceapi/face/findsimilar). No image will be stored. Only the extracted face features are stored on server until [LargeFaceList - Delete](https://docs.microsoft.com/rest/api/faceapi/largefacelist/delete) is called. <br /> Find Similar is used for scenario like finding celebrity-like faces, similar face filtering, or as a light way face identification. But if the actual use is to identify person, please use [PersonGroup](https://docs.microsoft.com/rest/api/faceapi/persongroup) / [LargePersonGroup](https://docs.microsoft.com/rest/api/faceapi/largepersongroup) and [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify). <br/>’recognitionModel’ should be specified to associate with this large face list. The default value for ‘recognitionModel’ is ‘recognition_01’, if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing large face list will use the recognition model that’s already associated with the collection. Existing face features in a large face list can’t be updated to features extracted by another version of recognition model. Please refer to [Specify a recognition model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model). Large face list quota: * Free-tier subscription quota: 64 large face lists. * S0-tier subscription quota: 1,000,000 large face lists.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • recognition_model (str or RecognitionModel) – Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete(large_face_list_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a specified large face list.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete_face(large_face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a face from a large face list by specified largeFaceListId and persistedFaceId. <br /> Adding/deleting faces to/from a same large face list are processed sequentially and to/from different large face lists are in parallel.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(large_face_list_id, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

Retrieve a large face list’s largeFaceListId, name, userData and recognitionModel.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

LargeFaceList or ClientRawResponse if raw=true

Return type

LargeFaceList or ClientRawResponse

Raises

APIErrorException

get_face(large_face_list_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve information about a persisted face (specified by persistedFaceId and its belonging largeFaceListId).

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

get_training_status(large_face_list_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve the training status of a large face list (completed or ongoing).

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

TrainingStatus or ClientRawResponse if raw=true

Return type

TrainingStatus or ClientRawResponse

Raises

APIErrorException

list(return_recognition_model=False, start=None, top=None, custom_headers=None, raw=False, **operation_config)[source]

List large face lists’ information of largeFaceListId, name, userData and recognitionModel. <br /> To get face information inside largeFaceList use [LargeFaceList Face - Get](https://docs.microsoft.com/rest/api/faceapi/largefacelist/getface)<br /> * Large face lists are stored in alphabetical order of largeFaceListId. * “start” parameter (string, optional) is a user-provided largeFaceListId value that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item. * “top” parameter (int, optional) specifies the number of entries to return. A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 large person lists: “list1”, …, “list5”. <br /> “start=&top=” will return all 5 lists. <br /> “start=&top=2” will return “list1”, “list2”. <br /> “start=list2&top=3” will return “list3”, “list4”, “list5”. .

Parameters
  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • start (str) – Starting large face list id to return (used to list a range of large face lists).

  • top (int) – Number of large face lists to return starting with the large face list id indicated by the ‘start’ parameter.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[LargeFaceList] or ClientRawResponse

Raises

APIErrorException

list_faces(large_face_list_id, start=None, top=None, custom_headers=None, raw=False, **operation_config)[source]

List all faces in a large face list, and retrieve face information (including userData and persistedFaceIds of registered faces of the face).

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • start (str) – Starting face id to return (used to list a range of faces).

  • top (int) – Number of faces to return starting with the face id indicated by the ‘start’ parameter.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[PersistedFace] or ClientRawResponse

Raises

APIErrorException

train(large_face_list_id, custom_headers=None, raw=False, **operation_config)[source]

Queue a large face list training task, the training task may not be started immediately.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update(large_face_list_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update information of a large face list.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update_face(large_face_list_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update a persisted face’s userData field.

Parameters
  • large_face_list_id (str) – Id referencing a particular large face list.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • user_data (str) – User-provided data attached to the face. The size limit is 1KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.LargePersonGroupOperations(client, config, serializer, deserializer)[source]

Bases: object

LargePersonGroupOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

create(large_person_group_id, name, user_data=None, recognition_model='recognition_01', custom_headers=None, raw=False, **operation_config)[source]

Create a new large person group with user-specified largePersonGroupId, name, an optional userData and recognitionModel. <br /> A large person group is the container of the uploaded person data, including face recognition feature, and up to 1,000,000 people. <br /> After creation, use [LargePersonGroup Person - Create](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/create) to add person into the group, and call [LargePersonGroup - Train](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/train) to get this group ready for [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify). <br /> No image will be stored. Only the person’s extracted face features and userData will be stored on server until [LargePersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/delete) or [LargePersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/delete) is called. <br/>’recognitionModel’ should be specified to associate with this large person group. The default value for ‘recognitionModel’ is ‘recognition_01’, if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing large person group will use the recognition model that’s already associated with the collection. Existing face features in a large person group can’t be updated to features extracted by another version of recognition model. Please refer to [Specify a face recognition model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-recognition-model). Large person group quota: * Free-tier subscription quota: 1,000 large person groups. * S0-tier subscription quota: 1,000,000 large person groups.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • recognition_model (str or RecognitionModel) – Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete(large_person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Delete an existing large person group. Persisted face features of all people in the large person group will also be deleted.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(large_person_group_id, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

Retrieve the information of a large person group, including its name, userData and recognitionModel. This API returns large person group information only, use [LargePersonGroup Person - List](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/list) instead to retrieve person information under the large person group. .

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

LargePersonGroup or ClientRawResponse if raw=true

Return type

LargePersonGroup or ClientRawResponse

Raises

APIErrorException

get_training_status(large_person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve the training status of a large person group (completed or ongoing).

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

TrainingStatus or ClientRawResponse if raw=true

Return type

TrainingStatus or ClientRawResponse

Raises

APIErrorException

list(start=None, top=1000, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

List all existing large person groups’ largePersonGroupId, name, userData and recognitionModel.<br /> * Large person groups are stored in alphabetical order of largePersonGroupId. * “start” parameter (string, optional) is a user-provided largePersonGroupId value that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item. * “top” parameter (int, optional) specifies the number of entries to return. A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 large person groups: “group1”, …, “group5”. <br /> “start=&top=” will return all 5 groups. <br /> “start=&top=2” will return “group1”, “group2”. <br /> “start=group2&top=3” will return “group3”, “group4”, “group5”. .

Parameters
  • start (str) – List large person groups from the least largePersonGroupId greater than the “start”.

  • top (int) – The number of large person groups to list.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[LargePersonGroup] or ClientRawResponse

Raises

APIErrorException

train(large_person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Queue a large person group training task, the training task may not be started immediately.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update(large_person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update an existing large person group’s display name and userData. The properties which does not appear in request body will not be updated.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.LargePersonGroupPersonOperations(client, config, serializer, deserializer)[source]

Bases: object

LargePersonGroupPersonOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

add_face_from_stream(large_person_group_id, person_id, image, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, callback=None, **operation_config)[source]

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/deleteface), [LargePersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/delete) or [LargePersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Each person entry can hold up to 248 faces. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • image (Generator) – An image stream.

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • callback (Callable[Bytes, response=None]) – When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None.

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

add_face_from_url(large_person_group_id, person_id, url, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, **operation_config)[source]

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/deleteface), [LargePersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroupperson/delete) or [LargePersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/largepersongroup/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Each person entry can hold up to 248 faces. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • url (str) – Publicly reachable URL of an image

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

create(large_person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Create a new person in a specified large person group.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

Person or ClientRawResponse if raw=true

Return type

Person or ClientRawResponse

Raises

APIErrorException

delete(large_person_group_id, person_id, custom_headers=None, raw=False, **operation_config)[source]

Delete an existing person from a large person group. The persistedFaceId, userData, person name and face feature in the person entry will all be deleted.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete_face(large_person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a face from a person in a large person group by specified largePersonGroupId, personId and persistedFaceId. <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(large_person_group_id, person_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve a person’s name and userData, and the persisted faceIds representing the registered person face feature.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

Person or ClientRawResponse if raw=true

Return type

Person or ClientRawResponse

Raises

APIErrorException

get_face(large_person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId).

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

list(large_person_group_id, start=None, top=None, custom_headers=None, raw=False, **operation_config)[source]

List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person).

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • start (str) – Starting person id to return (used to list a range of persons).

  • top (int) – Number of persons to return starting with the person id indicated by the ‘start’ parameter.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[Person] or ClientRawResponse

Raises

APIErrorException

update(large_person_group_id, person_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update name or userData of a person.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update_face(large_person_group_id, person_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update a person persisted face’s userData field.

Parameters
  • large_person_group_id (str) – Id referencing a particular large person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • user_data (str) – User-provided data attached to the face. The size limit is 1KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.PersonGroupOperations(client, config, serializer, deserializer)[source]

Bases: object

PersonGroupOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

create(person_group_id, name, user_data=None, recognition_model='recognition_01', custom_headers=None, raw=False, **operation_config)[source]

Create a new person group with specified personGroupId, name, user-provided userData and recognitionModel. <br /> A person group is the container of the uploaded person data, including face recognition features. <br /> After creation, use [PersonGroup Person - Create](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/create) to add persons into the group, and then call [PersonGroup - Train](https://docs.microsoft.com/rest/api/faceapi/persongroup/train) to get this group ready for [Face - Identify](https://docs.microsoft.com/rest/api/faceapi/face/identify). <br /> No image will be stored. Only the person’s extracted face features and userData will be stored on server until [PersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/delete) or [PersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroup/delete) is called. <br/>’recognitionModel’ should be specified to associate with this person group. The default value for ‘recognitionModel’ is ‘recognition_01’, if the latest model needed, please explicitly specify the model you need in this parameter. New faces that are added to an existing person group will use the recognition model that’s already associated with the collection. Existing face features in a person group can’t be updated to features extracted by another version of recognition model. Person group quota: * Free-tier subscription quota: 1,000 person groups. Each holds up to 1,000 persons. * S0-tier subscription quota: 1,000,000 person groups. Each holds up to 10,000 persons. * to handle larger scale face identification problem, please consider using [LargePersonGroup](https://docs.microsoft.com/rest/api/faceapi/largepersongroup).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • recognition_model (str or RecognitionModel) – Possible values include: ‘recognition_01’, ‘recognition_02’, ‘recognition_03’, ‘recognition_04’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete(person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Delete an existing person group. Persisted face features of all people in the person group will also be deleted.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(person_group_id, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

Retrieve person group name, userData and recognitionModel. To get person information under this personGroup, use [PersonGroup Person - List](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/list).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersonGroup or ClientRawResponse if raw=true

Return type

PersonGroup or ClientRawResponse

Raises

APIErrorException

get_training_status(person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve the training status of a person group (completed or ongoing).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

TrainingStatus or ClientRawResponse if raw=true

Return type

TrainingStatus or ClientRawResponse

Raises

APIErrorException

list(start=None, top=1000, return_recognition_model=False, custom_headers=None, raw=False, **operation_config)[source]

List person groups’ personGroupId, name, userData and recognitionModel.<br /> * Person groups are stored in alphabetical order of personGroupId. * “start” parameter (string, optional) is a user-provided personGroupId value that returned entries have larger ids by string comparison. “start” set to empty to indicate return from the first item. * “top” parameter (int, optional) specifies the number of entries to return. A maximal of 1000 entries can be returned in one call. To fetch more, you can specify “start” with the last returned entry’s Id of the current call. <br /> For example, total 5 person groups: “group1”, …, “group5”. <br /> “start=&top=” will return all 5 groups. <br /> “start=&top=2” will return “group1”, “group2”. <br /> “start=group2&top=3” will return “group3”, “group4”, “group5”. .

Parameters
  • start (str) – List person groups from the least personGroupId greater than the “start”.

  • top (int) – The number of person groups to list.

  • return_recognition_model (bool) – A value indicating whether the operation should return ‘recognitionModel’ in response.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[PersonGroup] or ClientRawResponse

Raises

APIErrorException

train(person_group_id, custom_headers=None, raw=False, **operation_config)[source]

Queue a person group training task, the training task may not be started immediately.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update(person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update an existing person group’s display name and userData. The properties which does not appear in request body will not be updated.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.PersonGroupPersonOperations(client, config, serializer, deserializer)[source]

Bases: object

PersonGroupPersonOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

add_face_from_stream(person_group_id, person_id, image, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, callback=None, **operation_config)[source]

Add a face to a person into a person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [PersonGroup PersonFace - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/deleteface), [PersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/delete) or [PersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroup/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Each person entry can hold up to 248 faces. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • image (Generator) – An image stream.

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • callback (Callable[Bytes, response=None]) – When specified, will be called with each chunk of data that is streamed. The callback should take two arguments, the bytes of the current chunk of data and the response object. If the data is uploading, response will be None.

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

add_face_from_url(person_group_id, person_id, url, user_data=None, target_face=None, detection_model='detection_01', custom_headers=None, raw=False, **operation_config)[source]

Add a face to a person into a person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [PersonGroup PersonFace - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/deleteface), [PersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/delete) or [PersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroup/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Each person entry can hold up to 248 faces. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel. * The minimum detectable face size is 36x36 pixels in an image no larger than 1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size. * Different ‘detectionModel’ values can be provided. To use and compare different detection models, please refer to [How to specify a detection model](https://docs.microsoft.com/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • url (str) – Publicly reachable URL of an image

  • user_data (str) – User-specified data about the face for any purpose. The maximum length is 1KB.

  • target_face (list[int]) – A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image.

  • detection_model (str or DetectionModel) – Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is ‘detection_01’, if another model is needed, please explicitly specify it. Possible values include: ‘detection_01’, ‘detection_02’, ‘detection_03’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

create(person_group_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Create a new person in a specified person group.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

Person or ClientRawResponse if raw=true

Return type

Person or ClientRawResponse

Raises

APIErrorException

delete(person_group_id, person_id, custom_headers=None, raw=False, **operation_config)[source]

Delete an existing person from a person group. The persistedFaceId, userData, person name and face feature in the person entry will all be deleted.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete_face(person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Delete a face from a person in a person group by specified personGroupId, personId and persistedFaceId. <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(person_group_id, person_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve a person’s information, including registered persisted faces, name and userData.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

Person or ClientRawResponse if raw=true

Return type

Person or ClientRawResponse

Raises

APIErrorException

get_face(person_group_id, person_id, persisted_face_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging personGroupId).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

PersistedFace or ClientRawResponse if raw=true

Return type

PersistedFace or ClientRawResponse

Raises

APIErrorException

list(person_group_id, start=None, top=None, custom_headers=None, raw=False, **operation_config)[source]

List all persons in a person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person).

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • start (str) – Starting person id to return (used to list a range of persons).

  • top (int) – Number of persons to return starting with the person id indicated by the ‘start’ parameter.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[Person] or ClientRawResponse

Raises

APIErrorException

update(person_group_id, person_id, name=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update name or userData of a person.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • name (str) – User defined name, maximum length is 128.

  • user_data (str) – User specified data. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update_face(person_group_id, person_id, persisted_face_id, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Add a face to a person into a person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [PersonGroup PersonFace - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/deleteface), [PersonGroup Person - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroupperson/delete) or [PersonGroup - Delete](https://docs.microsoft.com/rest/api/faceapi/persongroup/delete) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl). * Higher face image quality means better recognition precision. Please consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger. * Each person entry can hold up to 248 faces. * JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed image file size is from 1KB to 6MB. * “targetFace” rectangle should contain one face. Zero or multiple faces will be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](https://docs.microsoft.com/rest/api/faceapi/face/detectwithurl), there’s no guarantee to detect and add the face successfully. * Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or large occlusions will cause failures. * Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

Parameters
  • person_group_id (str) – Id referencing a particular person group.

  • person_id (str) – Id referencing a particular person.

  • persisted_face_id (str) – Id referencing a particular persistedFaceId of an existing face.

  • user_data (str) – User-provided data attached to the face. The size limit is 1KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>
class azure.cognitiveservices.vision.face.operations.SnapshotOperations(client, config, serializer, deserializer)[source]

Bases: object

SnapshotOperations operations.

You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute.

Parameters
  • client – Client for service requests.

  • config – Configuration of service client.

  • serializer – An object model serializer.

  • deserializer – An object model deserializer.

apply(snapshot_id, object_id, mode='CreateNew', custom_headers=None, raw=False, **operation_config)[source]

Submit an operation to apply a snapshot to current subscription. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Applying snapshot is an asynchronous operation. An operation id can be obtained from the “Operation-Location” field in response header, to be used in OperationStatus - Get for tracking the progress of applying the snapshot. The target object id will be included in the “resourceLocation” field in OperationStatus - Get response when the operation status is “succeeded”.<br /> Snapshot applying time depends on the number of person and face entries in the snapshot object. It could be in seconds, or up to 1 hour for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. So the target subscription is required to apply the snapshot in 48 hours since its creation.<br /> Applying a snapshot will not block any other operations against the target object, however it is not recommended because the correctness cannot be guaranteed during snapshot applying. After snapshot applying is completed, all operations towards the target object can work as normal. Snapshot also includes the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> One snapshot can be applied multiple times in parallel, while currently only CreateNew apply mode is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the “objectId” in request body to avoid such conflicts.<br /> * Free-tier subscription quota: 100 apply operations per month. * S0-tier subscription quota: 100 apply operations per day.

Parameters
  • snapshot_id (str) – Id referencing a particular snapshot.

  • object_id (str) – User specified target object id to be created from the snapshot.

  • mode (str or SnapshotApplyMode) – Snapshot applying mode. Currently only CreateNew is supported, which means the apply operation will fail if target subscription already contains an object of same type and using the same objectId. Users can specify the “objectId” in request body to avoid such conflicts. Possible values include: ‘CreateNew’

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

delete(snapshot_id, custom_headers=None, raw=False, **operation_config)[source]

Delete an existing snapshot according to the snapshotId. All object data and information in the snapshot will also be deleted. Only the source subscription who took the snapshot can delete the snapshot. If the user does not delete a snapshot with this API, the snapshot will still be automatically deleted in 48 hours after creation.

Parameters
  • snapshot_id (str) – Id referencing a particular snapshot.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

get(snapshot_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve information about a snapshot. Snapshot is only accessible to the source subscription who took it, and target subscriptions included in the applyScope in Snapshot - Take.

Parameters
  • snapshot_id (str) – Id referencing a particular snapshot.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

Snapshot or ClientRawResponse if raw=true

Return type

Snapshot or ClientRawResponse

Raises

APIErrorException

get_operation_status(operation_id, custom_headers=None, raw=False, **operation_config)[source]

Retrieve the status of a take/apply snapshot operation.

Parameters
  • operation_id (str) – Id referencing a particular take/apply snapshot operation.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

OperationStatus or ClientRawResponse if raw=true

Return type

OperationStatus or ClientRawResponse

Raises

APIErrorException

list(type=None, apply_scope=None, custom_headers=None, raw=False, **operation_config)[source]

List all accessible snapshots with related information, including snapshots that were taken by the user, or snapshots to be applied to the user (subscription id was included in the applyScope in Snapshot - Take).

Parameters
  • type (str or SnapshotObjectType) – User specified object type as a search filter. Possible values include: ‘FaceList’, ‘LargeFaceList’, ‘LargePersonGroup’, ‘PersonGroup’

  • apply_scope (list[str]) – User specified snapshot apply scopes as a search filter. ApplyScope is an array of the target Azure subscription ids for the snapshot, specified by the user who created the snapshot by Snapshot - Take.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

list or ClientRawResponse if raw=true

Return type

list[Snapshot] or ClientRawResponse

Raises

APIErrorException

take(type, object_id, apply_scope, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Submit an operation to take a snapshot of face list, large face list, person group or large person group, with user-specified snapshot type, source object id, apply scope and an optional user data.<br /> The snapshot interfaces are for users to backup and restore their face data from one face subscription to another, inside same region or across regions. The workflow contains two phases, user first calls Snapshot - Take to create a copy of the source object and store it as a snapshot, then calls Snapshot - Apply to paste the snapshot to target subscription. The snapshots are stored in a centralized location (per Azure instance), so that they can be applied cross accounts and regions.<br /> Taking snapshot is an asynchronous operation. An operation id can be obtained from the “Operation-Location” field in response header, to be used in OperationStatus - Get for tracking the progress of creating the snapshot. The snapshot id will be included in the “resourceLocation” field in OperationStatus - Get response when the operation status is “succeeded”.<br /> Snapshot taking time depends on the number of person and face entries in the source object. It could be in seconds, or up to several hours for 1,000,000 persons with multiple faces.<br /> Snapshots will be automatically expired and cleaned in 48 hours after it is created by Snapshot - Take. User can delete the snapshot using Snapshot - Delete by themselves any time before expiration.<br /> Taking snapshot for a certain object will not block any other operations against the object. All read-only operations (Get/List and Identify/FindSimilar/Verify) can be conducted as usual. For all writable operations, including Add/Update/Delete the source object or its persons/faces and Train, they are not blocked but not recommended because writable updates may not be reflected on the snapshot during its taking. After snapshot taking is completed, all readable and writable operations can work as normal. Snapshot will also include the training results of the source object, which means target subscription the snapshot applied to does not need re-train the target object before calling Identify/FindSimilar.<br /> * Free-tier subscription quota: 100 take operations per month. * S0-tier subscription quota: 100 take operations per day.

Parameters
  • type (str or SnapshotObjectType) – User specified type for the source object to take snapshot from. Currently FaceList, PersonGroup, LargeFaceList and LargePersonGroup are supported. Possible values include: ‘FaceList’, ‘LargeFaceList’, ‘LargePersonGroup’, ‘PersonGroup’

  • object_id (str) – User specified source object id to take snapshot from.

  • apply_scope (list[str]) – User specified array of target Face subscription ids for the snapshot. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.

  • user_data (str) – User specified data about the snapshot for any purpose. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

update(snapshot_id, apply_scope=None, user_data=None, custom_headers=None, raw=False, **operation_config)[source]

Update the information of a snapshot. Only the source subscription who took the snapshot can update the snapshot.

Parameters
  • snapshot_id (str) – Id referencing a particular snapshot.

  • apply_scope (list[str]) – Array of the target Face subscription ids for the snapshot, specified by the user who created the snapshot when calling Snapshot - Take. For each snapshot, only subscriptions included in the applyScope of Snapshot - Take can apply it.

  • user_data (str) – User specified data about the snapshot for any purpose. Length should not exceed 16KB.

  • custom_headers (dict) – headers that will be added to the request

  • raw (bool) – returns the direct response alongside the deserialized response

  • operation_configOperation configuration overrides.

Returns

None or ClientRawResponse if raw=true

Return type

None or ClientRawResponse

Raises

APIErrorException

models = <module 'azure.cognitiveservices.vision.face.models' from '/mnt/vss/_work/1/s/sdk/cognitiveservices/azure-cognitiveservices-vision-face/.tox/sphinx/lib/python3.6/site-packages/azure/cognitiveservices/vision/face/models/__init__.py'>