Crop images using PASCAL VOC .xml annotations
If you already have PASCAL VOC .xml annotations for your images and if you would want to crop the images as per the bounding boxes of the annotations, this blog is for you.
I wanted to train Hearts, Spades, Clubs and Diamonds for classification task and I had images annotated for multiple labels as shown here.
This git hub repo helped me organize the data in two formats:
- As per the names of the images and cropping multiple labels using main.py.
- Organizing the cropped images as per the labels using main_classification.ipynb.
Clone the repo using:
Copy paste all the images and .xml annotations in the data folder.
If you face xmltodict module not found error, install it using commands here.
Often the image classification task demands the data to be organized as per the class labels. And thus it would be useful to use annotations and crop the objects of interests.
To learn more: check out.