From 6cf07e04574d1f6e7a35f4471ae06195b5579efa Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Mon, 29 Apr 2019 12:31:17 +0200 Subject: [PATCH 1/6] Add new model-option (recognition_2) to detect Adds a parameter that allows to control which version of the model to use on the detect parameter. It defaults to recognition_1 as not to break anything. --- cognitive_face/face.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cognitive_face/face.py b/cognitive_face/face.py index 1860cf2..47cad0d 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 = 1): """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( From 12c0f679b34142054d00ac621815f52419725f48 Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Mon, 29 Apr 2019 14:01:19 +0200 Subject: [PATCH 2/6] Add recognition_model to create Adds option to choose between newest and oldest recognition model. This affects how the model identifies faces and adds faces to persons. This does introduce possible errors as the recognition_model in the person_group has to match the recognition_model in face.detect. --- cognitive_face/person_group.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cognitive_face/person_group.py b/cognitive_face/person_group.py index 22f03d3..a4b800e 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. @@ -28,8 +31,12 @@ def create(person_group_id, name=None, user_data=None): 'name': name, 'userData': user_data, } + params = { + 'recognitionModel': "recognition_0"+str(recognition_model), + 'returnRecognitionModel': 'true' + } - return util.request('PUT', url, json=json) + return util.request('PUT', url, json=json, params=params) def delete(person_group_id): From 91c38ee37fcdbfa7ffc04599a8d488b553def1ca Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Mon, 29 Apr 2019 14:10:40 +0200 Subject: [PATCH 3/6] Changed default of recognition_model to 2 Changed the default of recognition_model to 2 so it matches the one in person_group.create --- cognitive_face/face.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cognitive_face/face.py b/cognitive_face/face.py index 47cad0d..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='', recognition_model = 1): +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. From 482b4f6ce38132d95c9c960b27bed0bf0e4f21d0 Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Wed, 1 May 2019 13:30:38 +0200 Subject: [PATCH 4/6] Add return recognitionModel to get --- cognitive_face/person_group.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cognitive_face/person_group.py b/cognitive_face/person_group.py index a4b800e..2e0f9b5 100644 --- a/cognitive_face/person_group.py +++ b/cognitive_face/person_group.py @@ -68,6 +68,9 @@ def get(person_group_id): The person group's information. """ url = 'persongroups/{}'.format(person_group_id) + params = { + 'returnRecognitionModel': 'true' + } return util.request('GET', url) From d21b9abaf4e19a646d3c701ea9c2900d9cdffe3d Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Wed, 1 May 2019 13:31:42 +0200 Subject: [PATCH 5/6] Small fix --- cognitive_face/person_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cognitive_face/person_group.py b/cognitive_face/person_group.py index 2e0f9b5..cae1e76 100644 --- a/cognitive_face/person_group.py +++ b/cognitive_face/person_group.py @@ -72,7 +72,7 @@ def get(person_group_id): 'returnRecognitionModel': 'true' } - return util.request('GET', url) + return util.request('GET', url, params=params) def get_status(person_group_id): From 09a35db761ad37f181290cf0e4e250c86cf71343 Mon Sep 17 00:00:00 2001 From: Rysias <39084161+Rysias@users.noreply.github.com> Date: Mon, 6 May 2019 14:49:27 +0200 Subject: [PATCH 6/6] Test of recognition_model Changed recognitionModel from params to json to see if it works... --- cognitive_face/person_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cognitive_face/person_group.py b/cognitive_face/person_group.py index cae1e76..a2b7c5b 100644 --- a/cognitive_face/person_group.py +++ b/cognitive_face/person_group.py @@ -30,9 +30,9 @@ def create(person_group_id, name=None, user_data=None, recognition_model=2): json = { 'name': name, 'userData': user_data, + 'recognitionModel': "recognition_0"+str(recognition_model) } params = { - 'recognitionModel': "recognition_0"+str(recognition_model), 'returnRecognitionModel': 'true' }