diff --git a/cognitive_face/face.py b/cognitive_face/face.py index 1860cf2..4d4e9ae 100644 --- a/cognitive_face/face.py +++ b/cognitive_face/face.py @@ -7,7 +7,7 @@ from . import util -def detect(image, face_id=True, landmarks=False, attributes=''): +def detect(image, face_id=True, landmarks=False, attributes='', recognition_model=2): """Detect human faces in an image and returns face locations, and optionally with `face_id`s, landmarks, and attributes. @@ -23,6 +23,9 @@ def detect(image, face_id=True, landmarks=False, attributes=''): headPose, smile, facialHair, glasses, emotion, makeup, accessories, occlusion, blur, exposure, noise. Note that each face attribute analysis has additional computational and time cost. + recognition_model: [Optional] Choose which model to use. At this moment + there are two possibilites: 1 (the original model) or 2 (the updated + model). Both should be input as an integer. Returns: An array of face entries ranked by face rectangle size in descending @@ -35,6 +38,8 @@ def detect(image, face_id=True, landmarks=False, attributes=''): 'returnFaceId': face_id and 'true' or 'false', 'returnFaceLandmarks': landmarks and 'true' or 'false', 'returnFaceAttributes': attributes, + 'recognitionModel': "recognition_0"+str(recognition_model), + 'returnRecognitionModel': 'true' } return util.request( diff --git a/cognitive_face/person_group.py b/cognitive_face/person_group.py index 22f03d3..a2b7c5b 100644 --- a/cognitive_face/person_group.py +++ b/cognitive_face/person_group.py @@ -7,7 +7,7 @@ from . import util -def create(person_group_id, name=None, user_data=None): +def create(person_group_id, name=None, user_data=None, recognition_model=2): """Create a new person group with specified `person_group_id`, `name` and user-provided `user_data`. @@ -18,6 +18,9 @@ def create(person_group_id, name=None, user_data=None): name: Person group display name. The maximum length is 128. user_data: User-provided data attached to the person group. The size limit is 16KB. + recognition_model: [Optional] Choose which model to use. At this moment + there are two possibilites: 1 (the original model) or 2 (the updated + model). Both should be input as an integer. Returns: An empty response body. @@ -27,9 +30,13 @@ def create(person_group_id, name=None, user_data=None): json = { 'name': name, 'userData': user_data, + 'recognitionModel': "recognition_0"+str(recognition_model) + } + params = { + 'returnRecognitionModel': 'true' } - return util.request('PUT', url, json=json) + return util.request('PUT', url, json=json, params=params) def delete(person_group_id): @@ -61,8 +68,11 @@ def get(person_group_id): The person group's information. """ url = 'persongroups/{}'.format(person_group_id) + params = { + 'returnRecognitionModel': 'true' + } - return util.request('GET', url) + return util.request('GET', url, params=params) def get_status(person_group_id):