Python Kairos API-库名称不是有效参数

Python Kairos API-库名称不是有效参数,python,python-3.x,face-detection,kairos-api,Python,Python 3.x,Face Detection,Kairos Api,我正在尝试使用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

我正在尝试使用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))

/detect
URL不接受任何
gallery\u名称

但是,以下URL中需要
gallery\u name

  • /gallery/view
  • /gallery/remove
  • /gallery/删除主题
  • /gallery/view\u主题
鉴于您的数据还包含一个
/subject\u id
,显然您需要重写对
/view\u subject
url的请求


res=requests.post('https://api.kairos.com/gallery/view_subject“,headers=headers,files=files,data=values\u enrol)

/detect
URL不接受任何
库名

但是,以下URL中需要
gallery\u name

  • /gallery/view
  • /gallery/remove
  • /gallery/删除主题
  • /gallery/view\u主题
鉴于您的数据还包含一个
/subject\u id
,显然您需要重写对
/view\u subject
url的请求


res=requests.post('https://api.kairos.com/gallery/view_subject“,headers=headers,files=files,data=values\u enrol)

非常感谢您的回答。非常感谢您的回答。