我正在尝试使用kairos API 进行人脸检测。我有以下 python 代码。但是,我收到一个错误:
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
我的代码:
#!/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))