Pascal VOC 2007/2012 Dataset. It has 20 objects: aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa, train, tvmonitor and additional 3 classes : head, hand, foot for person. Parameters --------
(path='data', dataset='2012', contain_classes_in_person=False)
| 1350 | |
| 1351 | |
| 1352 | def load_voc_dataset(path='data', dataset='2012', contain_classes_in_person=False): |
| 1353 | """Pascal VOC 2007/2012 Dataset. |
| 1354 | |
| 1355 | It has 20 objects: |
| 1356 | aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, diningtable, dog, horse, motorbike, person, pottedplant, sheep, sofa, train, tvmonitor |
| 1357 | and additional 3 classes : head, hand, foot for person. |
| 1358 | |
| 1359 | Parameters |
| 1360 | ----------- |
| 1361 | path : str |
| 1362 | The path that the data is downloaded to, defaults is ``data/VOC``. |
| 1363 | dataset : str |
| 1364 | The VOC dataset version, `2012`, `2007`, `2007test` or `2012test`. We usually train model on `2007+2012` and test it on `2007test`. |
| 1365 | contain_classes_in_person : boolean |
| 1366 | Whether include head, hand and foot annotation, default is False. |
| 1367 | |
| 1368 | Returns |
| 1369 | --------- |
| 1370 | imgs_file_list : list of str |
| 1371 | Full paths of all images. |
| 1372 | imgs_semseg_file_list : list of str |
| 1373 | Full paths of all maps for semantic segmentation. Note that not all images have this map! |
| 1374 | imgs_insseg_file_list : list of str |
| 1375 | Full paths of all maps for instance segmentation. Note that not all images have this map! |
| 1376 | imgs_ann_file_list : list of str |
| 1377 | Full paths of all annotations for bounding box and object class, all images have this annotations. |
| 1378 | classes : list of str |
| 1379 | Classes in order. |
| 1380 | classes_in_person : list of str |
| 1381 | Classes in person. |
| 1382 | classes_dict : dictionary |
| 1383 | Class label to integer. |
| 1384 | n_objs_list : list of int |
| 1385 | Number of objects in all images in ``imgs_file_list`` in order. |
| 1386 | objs_info_list : list of str |
| 1387 | Darknet format for the annotation of all images in ``imgs_file_list`` in order. ``[class_id x_centre y_centre width height]`` in ratio format. |
| 1388 | objs_info_dicts : dictionary |
| 1389 | The annotation of all images in ``imgs_file_list``, ``{imgs_file_list : dictionary for annotation}``, |
| 1390 | format from `TensorFlow/Models/object-detection <https://github.com/tensorflow/models/blob/master/object_detection/create_pascal_tf_record.py>`__. |
| 1391 | |
| 1392 | Examples |
| 1393 | ---------- |
| 1394 | >>> imgs_file_list, imgs_semseg_file_list, imgs_insseg_file_list, imgs_ann_file_list, |
| 1395 | >>> classes, classes_in_person, classes_dict, |
| 1396 | >>> n_objs_list, objs_info_list, objs_info_dicts = tl.files.load_voc_dataset(dataset="2012", contain_classes_in_person=False) |
| 1397 | >>> idx = 26 |
| 1398 | >>> print(classes) |
| 1399 | ['aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor'] |
| 1400 | >>> print(classes_dict) |
| 1401 | {'sheep': 16, 'horse': 12, 'bicycle': 1, 'bottle': 4, 'cow': 9, 'sofa': 17, 'car': 6, 'dog': 11, 'cat': 7, 'person': 14, 'train': 18, 'diningtable': 10, 'aeroplane': 0, 'bus': 5, 'pottedplant': 15, 'tvmonitor': 19, 'chair': 8, 'bird': 2, 'boat': 3, 'motorbike': 13} |
| 1402 | >>> print(imgs_file_list[idx]) |
| 1403 | data/VOC/VOC2012/JPEGImages/2007_000423.jpg |
| 1404 | >>> print(n_objs_list[idx]) |
| 1405 | 2 |
| 1406 | >>> print(imgs_ann_file_list[idx]) |
| 1407 | data/VOC/VOC2012/Annotations/2007_000423.xml |
| 1408 | >>> print(objs_info_list[idx]) |
| 1409 | 14 0.173 0.461333333333 0.142 0.496 |
nothing calls this directly
no test coverage detected
searching dependent graphs…