我已经成功创建了一个使用 20 个类的分类器,每个类有 200 个图像。当我尝试向此分类器添加其他类时,API 调用失败:
Traceback (most recent call last):
File "create_classifier.py", line 34, in <module>
print visual_recognition.update_classifier('flowers_1337689264', **myhash)
File "/usr/local/lib/python2.7/dist-packages/watson_developer_cloud/visual_recognition_v3.py", line 96, in update_classifier
params=params, accept_json=True)
File "/usr/local/lib/python2.7/dist-packages/watson_developer_cloud/watson_developer_cloud_service.py", line 268, in request
raise WatsonException(error_message)
watson_developer_cloud.watson_developer_cloud_service.WatsonException: Unknown error
这是我的代码:
import json
from watson_developer_cloud import VisualRecognitionV3
from glob import glob
visual_recognition = VisualRecognitionV3('2016-05-20', api_key='xxxx')
myhash = {}
for f in sorted(glob('*.zip'))[20:30]:
clas = f.replace('.zip','');
clas = clas.replace(' ', '-')
clas += '_positive_examples'
myhash[clas] = open(f, 'rb')
print myhash
#print visual_recognition.create_classifier('test', **myhash)
print visual_recognition.update_classifier('test_1337689264', **myhash)