IBM Developer Blog

Follow the latest happenings with IBM Developer and stay in the know.

Work with an already existing dataset that was created outside of Maximo Visual Inspection

A lot of work has gone into the labeling UI for IBM Maximo Visual Inspection (MVI). However, there are situations where you want to work with an already existing dataset that was created outside of MVI. Thankfully, MVI already supports importing COCO datasets, label information and all. That’s easy enough. But what if you want to modify or add some images before importing that dataset? Maybe you have some colleagues without access to MVI who need you to keep things in a common format? Or maybe there are other tools that interact with these datasets? We can’t expect everyone else to use MVI’s dataset format.

I’m hoping this post will help you along in figuring how to do what you need to do outside of MVI. We’re going to create our own little COCO dataset with LabelMe and LabelMe2coco, and turn that into an MVI dataset that we can train MVI models with.

Creating the dataset

I like cats. So, I’m going to be using some cat pictures to create a bounding-box object detection model in MVI. However, I’m sure you’ll be creating datasets for much more important deep learning tasks, like finding manufacturing defects or classifying healthy and cancerous tissue. Still, you can download the small collection of cat pictures I’m using here. Make sure to unzip it.

Installing and using LabelMe

We have the images that are going to go into our dataset. Next, we need to label it. So, let’s get started with installing LabelMe. I prefer to use Anaconda and its simple-to-use environment system for installing things like this. That’s what we’ll go with here. However, installing LabelMe is pretty straightforward whatever package manager you use.

If you’re using Anaconda, create a new conda environment and activate it.

conda create --name labelme-env python=3.6
source activate labelme-env

Have pip install LabelMe into our new environment.

pip install labelme

Once LabelMe is installed, start it up.


Select Open Dir and choose the directory with your dataset-to-be. LabelMe should show you the first image in the center, and a list of all the images in the directory (probably in the bottom right). Now you can label your image with bounding-boxes, polygons, or classification labels.

When you’ve labeled this one, go on to the next image and make sure to save the XML file with the label data when prompted each time you label. LabelMe should automatically fill in a good name for you.

Note: LabelMe has some keyboard shortcuts that make this whole process much easier

Converting to the COCO format

Now that you’ve got a dataset with images and labels, we need to convert it from LabelMe’s format to the COCO format. There’s a handy script called out there that will do all of the hard work. Grab it from GitHub.

git clone
cd labelme2coco

Once you’ve got the repo cloned, we can run the script, feeding it the directory name of our dataset. The script will run through all the LabelMe XML files, read their label information, and create a single JSON file containing all the label information in the COCO format.

python <dataset dir>

Now we should have a directory containing our images, the LabelMe XML label files, and the COCO XML label file. We need to zip things up before we import that dataset into MVI.

zip *.json *.jpg

Our dataset is now ready to upload into MVI.

Importing COCO datasets into IBM Maximo Visual Inspection

Before importing the contents of our COCO annotated dataset into MVI, we need to first create the dataset in MVI. Log into MVI, and navigate to the Datasets page.

  1. Click Datasets in the top navbar.
  2. Then, click Create new data set and give it a name.
  3. Click Create.

    Note: Do not try to import our COCO dataset with the “Import .zip file” option. That option is for datasets in the MVI format. For the COCO format, MVI expects us to create a new dataset and then import our data. Now, we should be looking at our empty dataset in MVI.

  4. Click the Import Files button

  5. Select the .zip file we created in the last section and upload it.

Once everything is uploaded, we’re good to go. We can use our custom COCO dataset just like any other in MVI.

What do you think? Leave me a comment and let me know.