0
votes

I have the following IBM Watson Visual Recognition Python SDK for creating a simple classifier:

with open(os.path.dirname("/home/xxx/Desktop/Husky.zip/"), 'rb') as dogs, \ 
    open(os.path.dirname("/home/xxx/Desktop/Husky.zip/"), 'rb') as cats:
    print(json.dumps(visual_recognition.create_classifier('Dogs Vs Cats',dogs_positive_examples=dogs,negative_examples=cats), indent=2))

The response with the new classifier ID and its status is as follows:

{
  "status": "training", 
  "name": "Dogs Vs Cats", 
  "created": "2016-06-23T06:30:00.115Z", 
  "classes": [
    {
      "class": "dogs"
    }
  ], 
  "owner": "840ad7db-1e17-47bd-9961-fc43f35d2ad0", 
  "classifier_id": "DogsVsCats_250748237"
}

The training status shows failed.

print(json.dumps(visual_recognition.list_classifiers(), indent=4))

{
    "classifiers": [
        {
            "status": "failed", 
            "classifier_id": "DogsVsCats_250748237", 
            "name": "Dogs Vs Cats"
        }
    ]
}

What is the cause of this?

2
Make sure the zip only has images. If you open a terminal you can see the zip file content using unzip - German Attanasio

2 Answers

1
votes
with open(os.path.dirname("/home/xxx/Desktop/Husky.zip/"), 'rb') as dogs, \ 
    open(os.path.dirname("/home/xxx/Desktop/Husky.zip/"), 'rb') as cats:
    print(json.dumps(visual_recognition.create_classifier('Dogs Vs Cats',dogs_positive_examples=dogs,negative_examples=cats), indent=2))

You are sending the same file contents "Husky.zip" for the service to use as both the positive and negative examples. However, the system requires at least 10 positive examples and 10 negative example images which are unique. The service compares the hashcode of the image file contents before training, and leaves any duplicates only in the positive set. So, your negative set is empty after de-duplication, leading to training failure. There should be an additional field called "explanation" in the verbose listing of your classifier details, saying this may be the problem.

1
votes

There are size limitations for training calls and data:

The service accepts a maximum of 10,000 images or 100 MB per .zip file

The service requires a minimum of 10 images per .zip file.

The service accepts a maximum of 256 MB per training call.

There are also size limitations for classification calls:

The POST /v3/classify methods accept a maximum of 20 images per batch.

The POST /v3/detect_faces methods accept a maximum of 15 images per batch.

The POST /v3/recognize_text methods accept a maximum of 10 images per batch.

see http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/doc/visual-recognition/customizing.shtml