APIErrorException: (BadArgument) 'recognitionModel' 不兼容:AZURE COGNITIVE FACE



我正在使用AZURE COGNITIVE FACE API创建考勤系统。我正在将考勤表存储在excel表中。但是出现了一个错误"recogrationModel不兼容。"从文档中我了解到有两个识别模型(recogration_01,recogration_02(。是否需要提及类型?如果是这样,如何在python中做到这一点?

错误:

File "identify.py", line 58, in <module>
res = face_client.face.identify(faceIds, global_var.personGroupId)
File "C:PythonPython36libsite-packagesazurecognitiveservicesvisionfaceoperations_face_operations.py", line 313, in identify
raise models.APIErrorException(self._deserialize, response)
azure.cognitiveservices.vision.face.models._models_py3.APIErrorException: (BadArgument) 'recognitionModel' is incompatible.

代码:

from msrest.authentication import CognitiveServicesCredentials
from azure.cognitiveservices.vision.face.models import TrainingStatusType, Person, SnapshotObjectType, OperationStatusType
import global_variables as global_var
import os, urllib
import sqlite3
from openpyxl import Workbook, load_workbook
from openpyxl.utils import get_column_letter, column_index_from_string
from openpyxl.cell import Cell
import time
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

#get current date
currentDate = time.strftime("%d_%m_%y")
wb = load_workbook(filename = "reports.xlsx")
sheet = wb['Cse16']
def getDateColumn():
for i in range(1, len(list(sheet.rows)[0]) + 1):
col = get_column_letter(i)
if sheet['%s%s'% (col,'1')].value == currentDate:
return col
Key = global_var.key

ENDPOINT = 'https://centralindia.api.cognitive.microsoft.com'
face_client = FaceClient(ENDPOINT,CognitiveServicesCredentials(Key))

connect = sqlite3.connect("Face-DataBase")

attend = [0 for i in range(60)] 
currentDir = os.path.dirname(os.path.abspath(__file__))
directory = os.path.join(currentDir, 'Cropped_faces')
for filename in os.listdir(directory):
if filename.endswith(".jpg"):
print(filename)
img_data = open(os.path.join(directory,filename), 'r+b')
res = face_client.face.detect_with_stream(img_data)
print("Res = {}".format(res))
if len(res) < 1:
print("No face detected.")
continue
faceIds = []
for face in res:
faceIds.append(face.face_id)
res = face_client.face.identify(faceIds, global_var.personGroupId)   #Error occuring line
#print(filename)
print("res = {}".format(res))
for face  in res:
if not face['candidates']:
print("Unknown")
else:
personId = face['candidates'][0]['personId']
print("personid = {}".format(personId))
#cmd =  + personId
cur = connect.execute("SELECT * FROM Students WHERE personID = (?)", (personId,))
#print("cur = {}".format(cur))
for row in cur:
print("aya")
print("row = {}".format(row))
attend[int(row[0])] += 1
print("---------- " + row[1] + " recognized ----------")
time.sleep(6)
for row in range(2, len(list(sheet.columns)[0]) + 1):
rn = sheet.cell(row = row, column  =1).value
if rn is not None:
print("rn = {}".format(rn))
rn = rn[-2:]
if attend[int(rn)] != 0:
col = getDateColumn()
print("col = {}".format(col))
sheet['%s%s' % (col, str(row))] = 0
wb.save(filename = "reports.xlsx")

Identify操作的服务文档门户中所述(例如西欧,但所有地区都相同(:

与查询面的faceId关联的"identificationModel"应该与目标人员组使用的"identificationModel"相同或大型团体。

所以这里看起来不匹配。您不必在Identify操作中传递identificationModel,而是在您首先执行的Detect操作中传递。

您必须确保该值与您想要识别人员的personGroup所使用的值相同(请参阅personGroup创建操作,包含识别变量(

相关内容

  • 没有找到相关文章

最新更新