Create a Dataset for Object Detection
Last Updated on June 2, 2020 by Editorial Team
Author(s): Pushkar Pushp
Computer Vision
Introduction
The first step for most computer vision tasks such as classification, segmentation, or detection is to have custom data for your problem set. There are multiple ways of creating labeled data; one such method is annotations.
The annotation technique manually creates regions in an image and assign aΒ label.
Now to keep things simple, we will be using two tools Pixel Annotation tool and Microsoft VoTT. You can read more about this tool, Pixel and Microsoft VoTT.
Pixel Annotation Tools
Installation forΒ macOS.
git clone https://github.com/abreheret/PixelAnnotationTool
Then update brew using brewΒ update.
Next, you need to install a cross-platform application development framework such asΒ qt.
brew install qt
Pixel Annotation tool uses a watershed algorithm to do image segmentation.
Readers can use this link to read more about the watershed algorithm inΒ detail.
brew install opencv
In Mac curl is already installed, you can check it by using typing curl -V in the terminal.
Something like this will appear, else install curl usingΒ brew.
brew install curl
Pixel Annotation tool does not come up with aΒ .dmg file or a Graphic interface, so you need to transform source code to a stand-alone form viaΒ build.
cd PixelAnnotationTool
Inside this directory create theΒ build
mkdir build
cd build
Next, inside build use the following command:
cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DDISABLE_MAINTAINER_CFLAGS=off -DCMAKE_PREFIX_PATH=$(brew --prefix qt) -DQMAKE_PATH=$(brew --prefix qt)/bin
Finally,
cmake --build .
We are all set to run and use the Pixel Annotation tool.
Go to the spotlight and search for the Pixel Annotation tool.
Creating aΒ Dataset.
Go to the File option at the top left and select Open a directory.
On the top right, see all fileΒ names.
Select one image, say βSachin.jpg.β
Go to the color panel on the left side and select any color, let me set theΒ sky.
Move your cursor around the person (Sachin).
Then select another color say βout of roiβ and move the cursor around the entire region except for aΒ person.
Then click on the watershed option at the bottom left and press Command + S to save theΒ image.
Finally, you will get thisΒ mask.
Result
Input
Output
This mask serves as input for any object detection model.
Microsoft Visual Object Tagging ToolΒ (VoTT)
Installation forΒ macOS.
Unlike Pixel Annotation Tools, VoTT comes with Disk Image(dmg) file.
- You can download and install the tool from below link https://github.com/microsoft/VoTT/releases/download/v2.1.0/vott-2.1.0-darwin.dmg.
- Go to the spotlight and search for VoTT andΒ launch.
- Click on NewΒ Project
- Fill Display Name, say Cricketers in myΒ case.
- Add Source Connection, click on that a screen will pop upΒ like
- In Provider, select Local File System if your file to annotate is on theΒ Laptop.
- Select the folder where the images are and click on βSave Connection.β
- Once saved, something like below will appear, from source connection drop-down select βCricketers,β which we haveΒ created.
- Next, go to the target connection and add a connection.
Same as source, for target select Cricketers_annotations.
- At the bottom, there will beΒ Tags.
Enter the label you want, cricketers in ourΒ case.
- Save Project
A screen similar to this willΒ appear.
- In the left panel, you will see an arrow mark (fourth row ), click on that below screen willΒ appear.
From the Provider drop-down menu, select Pascal VOC and enter βSave Export Settings.β
Create a box around the player and select tag from right, then save it from the save option at theΒ top.
- Repeat this process for all images in the folder. Once done, we need to export theΒ output.
- At the top of the image, there is an Export projectΒ option.
Once exported, go to thatΒ folder.
In this blog, we learned how to create a dataset for object detection and segmentation. Next, I will walk through the conversion of this mask into polygon co-ordinates, annotations.
A directory Cricketers-PascalVOC-export creates at the target location providedΒ earlier.
Enjoy!
Create a Dataset for Object Detection was originally published in Towards AIβββMultidisciplinary Science Journal on Medium, where people are continuing the conversation by highlighting and responding to this story.
Published via Towards AI