对于容易制作的数据集应尽量自己制作
一、数据集准备及标注
1. 使用工具:roLabelImg
2. 使用Windows相机进行拍摄,结果如下图
3. 标注过程
4. 讲数据放入数组中
数组结构:
[
{‘filename’: ‘D:\darknet\img\1.jpg’,
‘width’: 640,
‘height’: 512,
‘object’: [
{‘name’: ‘metal’, ‘xmin’: 227, ‘ymin’: 134, ‘xmax’: 452, ‘ymax’: 371}
…
]
},
{}
…
]
import os
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 = {
}
for ann in sorted(os.listdir(ann_dir)):
if "xml" not in ann:
continue
img = {
'object':[]