-->

IBM Watson Visual recognition{“code”:400,“error”:“

2019-07-27 07:45发布

问题:

When I try to train a classifier with two positive classes and with the API key (each class contains around 1200 images) in Watson Visual Recognition, it returns that "no classifier name is given" - but that I have already provided. This is the code:

     $ curl -X POST -F "blank_positive_examples=@C:\Users\rahansen\Desktop\Altmuligt\training\no_ocd\no_ocd.zip" -F "OCD_positive_examples=@C:\Users\rahansen\Desktop\Altmuligt\training\ocd\ocd.zip" -F "name=disease" "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classifiers?api_key={X}&version=2016-05-20"

     {"code":400,"error":"Cannot execute learning task.  : no classifier name given"}

What I have done so far:

  1. Removed all special characters in the file names as I thought that might be the problem:
  2. Tried to give other names for the classifeir, e.g. "name=ocd"
  3. I also tried to train it on a smaller dataset, like 40 images in each positive class and then it actually works fine. So maybe the size of the dataset is the problem. However, according to Watson training guidelines, I comply with the size regulations: https://www.ibm.com/watson/developercloud/doc/visual-recognition/customizing.html I have a free subscription.

Do anyone has any recommendations for how to solve this classifier training problem?

回答1:

This can occur when there's a problem processing the zip files. I would try simplifying your training files. For instance, use just 100 examples for class, then you can add more via retraining later. It's always good to train then measure performance and then add more training samples.



回答2:

@Rasmus, you should verify the name their picture neatly, meaning no special symbols, spaces or etc. in the file name of images. It appears to be related to special characters in the input. This API expects only characters and numbers in the alphabet as classifier names. It also requires that the images in your zip files end with a file extension for images like .jpg, .jpeg, .gif or .png

So, after you rename the images, check if all have the correct formats, like .jpg, .png, and supported formats for Visual Recognition.

Replace {api-key} with the service credentials you copied in the first step. Modify the location of the {class}_positive_examples to point to where you saved the .zip files.

And, use your cURL like:

curl -X POST
 -F "blank_positive_examples=@C:\Users\rahansen\Desktop\Altmuligt\training\no_ocd\no_ocd.zip"
 -F "OCD_positive_examples=@C:\Users\rahansen\Desktop\Altmuligt\training\ocd\ocd.zip"
 -F "name=disease"
 "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classifiers?api_key={api-key}&version=2016-05-20"

Obs. Can be other problem, see Other ask about error with classifier name.

My example working in my PC computer:

 curl -X POST -F "dog_positive_examples=c:\Dogs.zip" -F "negative_examples=c:\Cats.zip" -F "name=dogs" "https://gateway-a.watsonplatform.net/visual-recognition/api/v3/classifiers?api_key={API KEY}&version=2016-05-20"

See the official reference here.