Skip to content

Commit 514b03b

Browse files
authored
Update Face SDK (#35687)
* Detection03 supports Blur face attribute * Regenerate SDK with the latest TypeSpec * Rename sample files * Add one sample for verify_face_to_face
1 parent 406d463 commit 514b03b

21 files changed

+277
-21
lines changed

sdk/face/azure-ai-vision-face/azure/ai/vision/face/_operations/_operations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18860,7 +18860,7 @@ def create_liveness_session(
1886018860
# JSON input template you can fill out and use as your body input.
1886118861
body = {
1886218862
"livenessOperationMode": "str", # Type of liveness mode the client should
18863-
follow. Required. "Passive"
18863+
follow. Required. Known values are: "Passive" and "PassiveActive".
1886418864
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1886518865
last for. Range is 60 to 86400 seconds. Default value is 600.
1886618866
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -19034,7 +19034,7 @@ def create_liveness_session(
1903419034
# JSON input template you can fill out and use as your body input.
1903519035
body = {
1903619036
"livenessOperationMode": "str", # Type of liveness mode the client should
19037-
follow. Required. "Passive"
19037+
follow. Required. Known values are: "Passive" and "PassiveActive".
1903819038
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1903919039
last for. Range is 60 to 86400 seconds. Default value is 600.
1904019040
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -19687,7 +19687,7 @@ def _create_liveness_with_verify_session(
1968719687
# JSON input template you can fill out and use as your body input.
1968819688
body = {
1968919689
"livenessOperationMode": "str", # Type of liveness mode the client should
19690-
follow. Required. "Passive"
19690+
follow. Required. Known values are: "Passive" and "PassiveActive".
1969119691
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1969219692
last for. Range is 60 to 86400 seconds. Default value is 600.
1969319693
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -19845,7 +19845,7 @@ def _create_liveness_with_verify_session_with_verify_image( # pylint: disable=n
1984519845
body = {
1984619846
"Parameters": {
1984719847
"livenessOperationMode": "str", # Type of liveness mode the client
19848-
should follow. Required. "Passive"
19848+
should follow. Required. Known values are: "Passive" and "PassiveActive".
1984919849
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session
1985019850
should last for. Range is 60 to 86400 seconds. Default value is 600.
1985119851
"deviceCorrelationId": "str", # Optional. Unique Guid per each

sdk/face/azure-ai-vision-face/azure/ai/vision/face/aio/_operations/_operations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16493,7 +16493,7 @@ async def create_liveness_session(
1649316493
# JSON input template you can fill out and use as your body input.
1649416494
body = {
1649516495
"livenessOperationMode": "str", # Type of liveness mode the client should
16496-
follow. Required. "Passive"
16496+
follow. Required. Known values are: "Passive" and "PassiveActive".
1649716497
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1649816498
last for. Range is 60 to 86400 seconds. Default value is 600.
1649916499
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -16667,7 +16667,7 @@ async def create_liveness_session(
1666716667
# JSON input template you can fill out and use as your body input.
1666816668
body = {
1666916669
"livenessOperationMode": "str", # Type of liveness mode the client should
16670-
follow. Required. "Passive"
16670+
follow. Required. Known values are: "Passive" and "PassiveActive".
1667116671
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1667216672
last for. Range is 60 to 86400 seconds. Default value is 600.
1667316673
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -17320,7 +17320,7 @@ async def _create_liveness_with_verify_session(
1732017320
# JSON input template you can fill out and use as your body input.
1732117321
body = {
1732217322
"livenessOperationMode": "str", # Type of liveness mode the client should
17323-
follow. Required. "Passive"
17323+
follow. Required. Known values are: "Passive" and "PassiveActive".
1732417324
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session should
1732517325
last for. Range is 60 to 86400 seconds. Default value is 600.
1732617326
"deviceCorrelationId": "str", # Optional. Unique Guid per each end-user
@@ -17478,7 +17478,7 @@ async def _create_liveness_with_verify_session_with_verify_image( # pylint: dis
1747817478
body = {
1747917479
"Parameters": {
1748017480
"livenessOperationMode": "str", # Type of liveness mode the client
17481-
should follow. Required. "Passive"
17481+
should follow. Required. Known values are: "Passive" and "PassiveActive".
1748217482
"authTokenTimeToLiveInSeconds": 0, # Optional. Seconds the session
1748317483
should last for. Range is 60 to 86400 seconds. Default value is 600.
1748417484
"deviceCorrelationId": "str", # Optional. Unique Guid per each

sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_enums.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,21 @@ class LivenessModel(str, Enum, metaclass=CaseInsensitiveEnumMeta):
213213

214214

215215
class LivenessOperationMode(str, Enum, metaclass=CaseInsensitiveEnumMeta):
216-
"""The operation mode for the liveness modal."""
216+
"""The liveness operation mode to drive the client’s end-user experience."""
217217

218218
PASSIVE = "Passive"
219-
"""The operation mode for the liveness modal."""
219+
"""Utilizes a passive liveness technique that requires no additional actions from the user.
220+
Requires normal indoor lighting and high screen brightness for optimal performance. And thus,
221+
this mode has a narrow operational envelope and will not be suitable for scenarios that
222+
requires the end-user’s to be in bright lighting conditions. Note: this is the only supported
223+
mode for the Mobile (iOS and Android) solution."""
224+
PASSIVE_ACTIVE = "PassiveActive"
225+
"""This mode utilizes a hybrid passive or active liveness technique that necessitates user
226+
cooperation. It is optimized to require active motion only under suboptimal lighting
227+
conditions. Unlike the passive mode, this mode has no lighting restrictions, and thus offering
228+
a broader operational envelope. This mode is preferable on Web based solutions due to the lack
229+
of automatic screen brightness control available on browsers which hinders the Passive mode’s
230+
operational envelope on Web based solutions."""
220231

221232

222233
class MaskType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_models.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ class CreateLivenessSessionContent(_model_base.Model):
231231
232232
All required parameters must be populated in order to send to server.
233233
234-
:ivar liveness_operation_mode: Type of liveness mode the client should follow. Required.
235-
"Passive"
234+
:ivar liveness_operation_mode: Type of liveness mode the client should follow. Required. Known
235+
values are: "Passive" and "PassiveActive".
236236
:vartype liveness_operation_mode: str or ~azure.ai.vision.face.models.LivenessOperationMode
237237
:ivar send_results_to_client: Whether or not to allow a '200 - Success' response body to be
238238
sent to the client, which may be undesirable for security reasons. Default is false, clients
@@ -253,7 +253,8 @@ class CreateLivenessSessionContent(_model_base.Model):
253253
"""
254254

255255
liveness_operation_mode: Union[str, "_models.LivenessOperationMode"] = rest_field(name="livenessOperationMode")
256-
"""Type of liveness mode the client should follow. Required. \"Passive\""""
256+
"""Type of liveness mode the client should follow. Required. Known values are: \"Passive\" and
257+
\"PassiveActive\"."""
257258
send_results_to_client: Optional[bool] = rest_field(name="sendResultsToClient")
258259
"""Whether or not to allow a '200 - Success' response body to be sent to the client, which may be
259260
undesirable for security reasons. Default is false, clients will receive a '204 - NoContent'

sdk/face/azure-ai-vision-face/azure/ai/vision/face/models/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FaceAttributeTypeDetection01(str, Enum, metaclass=CaseInsensitiveEnumMeta)
3131
class FaceAttributeTypeDetection03(str, Enum, metaclass=CaseInsensitiveEnumMeta):
3232
"""Available attribute options for detection_03 model."""
3333

34+
BLUR = FaceAttributeType.BLUR.value
3435
HEAD_POSE = FaceAttributeType.HEAD_POSE.value
3536
MASK = FaceAttributeType.MASK.value
3637

sdk/face/azure-ai-vision-face/samples/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ The async versions of the samples (the python sample files appended with `_async
1414

1515
Several Azure Face Python SDK samples are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Face:
1616

17-
* [samples_authentication.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_authentication.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_authentication_async.py)) - Examples for authenticating and creating the client:
17+
* [sample_authentication.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_authentication.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_authentication_async.py)) - Examples for authenticating and creating the client:
1818
* From a key
1919
* From Microsoft Entra ID
2020

21-
* [samples_face_liveness_detection.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_liveness_detection.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_liveness_detection_async.py)) - Examples for performing liveness detection
21+
* [sample_face_liveness_detection.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_async.py)) - Examples for performing liveness detection
2222

23-
* [samples_face_liveness_detection_with_verification.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_liveness_detection_with_verification.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_liveness_detection_with_verification_async.py)) - Examples for performing liveness detection with face verification
23+
* [sample_face_liveness_detection_with_verification.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_liveness_detection_with_verification_async.py)) - Examples for performing liveness detection with face verification
2424

25-
* [samples_face_detection.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_detection.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_detection_async.py)) - Examples for detecting human faces in an image:
25+
* [sample_face_detection.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_detection.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_detection_async.py)) - Examples for detecting human faces in an image:
2626
* From a binary data
2727
* From a URL
2828

29-
* [samples_face_grouping.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_grouping.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_face_grouping_async.py)) - Examples for dividing candidate faces into groups based on face similarity.
29+
* [sample_stateless_face_verification.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_stateless_face_verification.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_stateless_face_verification_async.py)) - Examples for verifying whether two faces belong to the same person.
3030

31-
* [samples_find_similar_faces.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_find_similar_faces.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/samples_find_similar_faces_async.py)) - Examples for searching the similar-looking faces from a set of candidate faces:
31+
* [sample_face_grouping.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_grouping.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_face_grouping_async.py)) - Examples for dividing candidate faces into groups based on face similarity.
32+
33+
* [sample_find_similar_faces.py](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_find_similar_faces.py) ([async version](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/face/azure-ai-vision-face/samples/sample_find_similar_faces_async.py)) - Examples for searching the similar-looking faces from a set of candidate faces:
3234
* From a faceId array
3335
* From a large face list
3436

@@ -52,7 +54,7 @@ pip install azure-ai-vision-face
5254

5355
1. Open a terminal window and `cd` to the directory that the samples are saved in.
5456
2. Set the environment variables specified in the sample file you wish to run.
55-
3. Follow the usage described in the file, e.g. `python samples_face_detection.py`
57+
3. Follow the usage described in the file, e.g. `python sample_face_detection.py`
5658

5759
## Next steps
5860

sdk/face/azure-ai-vision-face/samples/samples_face_detection.py renamed to sdk/face/azure-ai-vision-face/samples/sample_face_detection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def detect(self):
6464
recognition_model=FaceRecognitionModel.RECOGNITION_04,
6565
return_face_id=True,
6666
return_face_attributes=[
67+
FaceAttributeTypeDetection03.BLUR,
6768
FaceAttributeTypeDetection03.HEAD_POSE,
6869
FaceAttributeTypeDetection03.MASK,
6970
FaceAttributeTypeRecognition04.QUALITY_FOR_RECOGNITION,

sdk/face/azure-ai-vision-face/samples/samples_face_detection_async.py renamed to sdk/face/azure-ai-vision-face/samples/sample_face_detection_async.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ async def detect(self):
6565
recognition_model=FaceRecognitionModel.RECOGNITION_04,
6666
return_face_id=True,
6767
return_face_attributes=[
68+
FaceAttributeTypeDetection03.BLUR,
6869
FaceAttributeTypeDetection03.HEAD_POSE,
6970
FaceAttributeTypeDetection03.MASK,
7071
FaceAttributeTypeRecognition04.QUALITY_FOR_RECOGNITION,

0 commit comments

Comments
 (0)