Accelerate the value of multicloud with collaborative DevSecOps Learn more

Train a model with Watson Visual Recognition

The ideas behind machine learning have been around for decades, and the combination of fast hardware and continued research have provide an explosion of applications. One of the most powerful is Visual Recognition. With IBM Watson Visual Recognition you have access to APIs to classify images, but more importantly, you can create custom classifiers that will give power to your unique use cases. So, how to create a custom classifier, and how to do this using Watson Visual Recognition’s free tier? Let’s have a look…

The free tier of Watson Visual Recognition allows you to classify or train, totalling 1000 events per month. One of the best practices for creating a custom classifier is to provide as much data as possible. Even though the API will accept as few as 10 per class, we strongly recommend using a significantly greater amount of images to improve the performance and accuracy of your classifier, such as 100s or 1000s of images. With that in mind, I’ll show how to create a custom classifier with the CLI.



Use your image files that you wish to classify. Each category of image that you wish to classify should be in it’s own zip file, and for each you will need a label of the form:


For example, you can use the following files to create a classifier for dogs: and for a negative example:

Then, simply upload the files to create the classifier using curl. The files that serve as examples should be of the form:


and negative examples can just have the form:


Here’s how we do it with the example files, substituting the API key you have in your credentials for {api_key} and adding the path to the files you are using if they are not in the current directory:

curl -X POST \
--form "" \
--form "" \
--form "" \
--form "" \
--form "name=dogs" \