0

我在 Bluemix 中有以下 Python SDK 示例代码和输入图像文件以创建新的分类器。这是代码:

visual_recognition = VisualRecognitionV3('2016-05-20',api_key=apikey)with 
open('./cars.zip', 'rb') as cars, open('./trucks.zip', 'rb') as trucks:
            print(json.dumps(visual_recognition.create_classifier('Cars', 
            positive_examples=cars, negative_example=trucks), indent=2)) 
            print(json.dumps(visual_recognition.list_classifiers(), indent=2))

运行日志显示状态=失败。

我错过了什么?

17/6/2016 19:50:03  OUT App {
17/6/2016 19:50:03  OUT App "owner": "885160bd-637d-4f8f-b268-fed5df81d672",
17/6/2016 19:50:03  OUT App "classifier_id": "Cars_2004369051",
17/6/2016 19:50:03  OUT App "created": "2016-06-17T19:50:03.301Z",
17/6/2016 19:50:03  OUT App "name": "Cars",
17/6/2016 19:50:03  OUT App "classes": [],
17/6/2016 19:50:03  OUT App "status": "training"
17/6/2016 19:50:03  OUT App }
17/6/2016 19:50:05  OUT App {
17/6/2016 19:50:05  OUT App "classifiers": [
17/6/2016 19:50:05  OUT App {
17/6/2016 19:50:05  OUT App "name": "Cars",
17/6/2016 19:50:05  OUT App "classifier_id": "Cars_933017903",
17/6/2016 19:50:05  OUT App "status": "failed"
17/6/2016 19:50:05  OUT App },
4

1 回答 1

0
  1. 这对我有用:

    import json
    from watson_developer_cloud import VisualRecognitionV3 as vr
    instance =vr(api_key='apikey', version='2016-05-20')
    with open('./trucks.zip', 'rb') as trucks, \
        open('./cars.zip', 'rb') as cars:
        visual_recognition.create_classifier('CarsvsTrucks', cars_positive_examples=cars, negative_examples=trucks)
    
于 2017-03-04T16:41:34.350 回答