import matplotlib.pyplot as plt import numpy as np import os, cv2 %matplotlib inline LABELS = ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable','dog', 'horse', 'motorbike', 'person', 'pottedplant','sheep', 'sofa', 'train', 'tvmonitor']
Dowload VOC-dataset
In [2]:
train_image_folder = "../../VOCdevkit/VOC2012/JPEGImages/" train_annot_folder = "../../VOCdevkit/VOC2012/Annotations/"
In [3]:
import xml.etree.ElementTree as ET def parse_annotation(ann_dir, img_dir, labels=[]): ''' output: - Each element of the train_image is a dictionary containing the annoation infomation of an image. - seen_train_labels is the dictionary containing (key, value) = (the object class, the number of objects found in the images) ''' all_imgs = [] seen_labels = {}