Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Added recognition_model parameter #71

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cognitive_face/face.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -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(
Expand Down
16 changes: 13 additions & 3 deletions cognitive_face/person_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand All @@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand Down