I'm trying to face detection using kairos API. I have a following python code. But, I'm getting an error :
img1.jpg
================RESPONSE=====================
b'{\n\t"Errors": [\n\t\t{\n\t\t\t"ErrCode": 1003,\n\t\t\t"Message": "gallery_name is not a valid parameter"\n\t\t},\n\t\t{\n\t\t\t"ErrCode": 1003,\n\t\t\t"Message": "subject_id is not a valid parameter"\n\t\t}\n\t]\n}'
-1
My code:
#!/usr/bin/python3
import requests
import io
import http.client
import base64
import json
import glob, os
from os.path import basename
dir_path = "/home/Photos/"
path = "/home/Kairos/kairos_jason/"
os.chdir(dir_path)
for file in glob.glob("*.jpg"):
img_path = file
print(img_path)
files = {'image': (img_path, open(dir_path + img_path, 'rb'), 'image/jpg', {'Expires': '0'})}
headers = {
'app_id': "My_Id",
'app_key': "My_Key",
}
values_enrol = {
"subject_id" : "11",
"gallery_name" : "msc_galary"
}
res = requests.post('https://api.kairos.com/detect', headers=headers, files=files, data=values_enrol)
print("================RESPONSE=====================")
print(res.content)
strRes = str(res.content)
print(strRes.find("face_id"))
with open(path + os.path.splitext(img_path)[0] + ".txt" , 'w') as outfile:
outfile.write(str(res.content))
The /detect
URL doesn't accept any gallery_name
However, gallery_name
is needed in the following urls:
/gallery/view
/gallery/remove
/gallery/remove_subject
/gallery/view_subject
Given that your data is also including a subject_id
, it's clear that you need to rewrite your request towards the /view_subject
url
res = requests.post('https://api.kairos.com/gallery/view_subject', headers=headers, files=files, data=values_enrol)