I am trying to create image classifier based on MS API by using python.
At first, I would like follow a instruction via MSDN "How to identify Face" This instruction is based on C#, but I would like to refer and convert into python
https://msdn.microsoft.com/en-us/library/mt605327.aspx
And based on my analysis, in order to identify face, the procedure is like this.
2. Person Group - Create a Person Group API
Person - Create a Person API
Person – Add a Person Face 3. Train Person group Person Group – Train Person Group API. Person Group - Get Person Group Training Status
- Identify
Face – Identify.
Q1. How to create sub group like example? Below code basically create person group id and I am not sure how to add sub groups such as "Anna", "Bill", "Claire" in this case.
#Person Group - Create a Person Group API
group_id = 'myfriend'
params = urllib.urlencode({ 'personGroupId': group_id})
body = '{"name": "myfriend1","userData": "user_profivde_data"}'
print(body)
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("PUT", "/face/v1.0/persongroups/{personGroupId}?%s" % params, body, headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
Q2. How to add several user face data instead of url? it seems like it requires body for url which only can data one. I would like get several data upload via my disk.
# Person - Add a Person Face
params = urllib.urlencode({
# Request parameters
'personGroupId': 'myfriend1',
'personId': "f50119eb-5a61-479f-9c57-d2af4eb99c48",
'userData': '{r/media/ryan/Windows_D/xx/xx.jpg}',
#'targetFace': '{string}',
})
body = '{ "url": "" }'
try:
conn = httplib.HTTPSConnection('api.projectoxford.ai')
conn.request("POST", "/face/v1.0/persongroups/{personGroupId}/persons/{personId}/persistedFaces?%s" % params, body, headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
It would be very nice if someone has python code for image grouping by ms api.
Thanks for your help and I really appreciated it.