Training a visual recognition model can be repetitive and tedious. Users generally have to manually upload and label each individual image. This code pattern shows how to automate these repetitive tasks by monitoring a set of folders using a Python script. As images are added to each folder, they’ll be uploaded and labeled in IBM Visual Insights. Once enough images have been uploaded, an image recognition model will be trained.


This code pattern is targeted toward business users that utilize custom visual recognition models and would like to reduce the amount of time spent on manually tuning and retraining their models. This is accomplished through the use of a Python script that has the ability to monitor folders for changes. As images are added to each designated folder, the images are automatically uploaded to the IBM Visual Insights service and labelled accordingly. This greatly simplifies the training process because you don’t have to use the UI to upload and label each individual image. This enables you to continuously update IBM Visual Insights models without depending on a system administrator.

When you complete this code pattern, you’ll be able to:

  • Automate categorizing and uploading of images to IBM Visual Insights
  • Automate model training in IBM Visual Insights



  1. The user copies respective images to the category subfolders.
  2. The script counts the number of images added and determines if image count exceeds threshold.
  3. If image count exceeds “upload” threshold, the script executes a POST request and uploads images for each category.
  4. If image count exceeds “train” threshold, the script executes a POST request to begin training a model.


Get the detailed instructions in the README file. These steps will show you how to:

  1. Clone the repository.
  2. Create the image folder and subfolders.
  3. Fill in the configuration file.
  4. Start and test the script.
Kalonji Bankole

For more details click here >>>>

Leave a Reply

Your email address will not be published.