def load_annotations_gt(self):
     ret = []
     if self.rad_gt_format_coco_json.isChecked():
         ret = converter.coco2bb(self.dir_annotations_gt)
     elif self.rad_gt_format_cvat_xml.isChecked():
         ret = converter.cvat2bb(self.dir_annotations_gt)
     elif self.rad_gt_format_openimages_csv.isChecked():
         ret = converter.openimage2bb(self.dir_annotations_gt,
                                      self.dir_images_gt,
                                      BBType.GROUND_TRUTH)
     elif self.rad_gt_format_labelme_xml.isChecked():
         ret = converter.labelme2bb(self.dir_annotations_gt)
     elif self.rad_gt_format_pascalvoc_xml.isChecked():
         ret = converter.vocpascal2bb(self.dir_annotations_gt)
     elif self.rad_gt_format_imagenet_xml.isChecked():
         ret = converter.imagenet2bb(self.dir_annotations_gt)
     elif self.rad_gt_format_abs_values_text.isChecked():
         ret = converter.text2bb(self.dir_annotations_gt,
                                 bb_type=BBType.GROUND_TRUTH)
     elif self.rad_gt_format_yolo_text.isChecked():
         ret = converter.yolo2bb(self.dir_annotations_gt,
                                 self.dir_images_gt,
                                 self.filepath_classes_gt,
                                 bb_type=BBType.GROUND_TRUTH)
     # Make all types as GT
     [bb.set_bb_type(BBType.GROUND_TRUTH) for bb in ret]
     return ret
def test_converters_gts():
    # Defining paths with images and annotations
    images_dir = 'data/database/images'
    gts_dir = 'data/database/gts'
    assert os.path.isdir(images_dir)
    assert os.path.isdir(gts_dir)

    # COCO
    coco_dir = os.path.join(gts_dir, 'coco_format_v1')
    coco_bbs_v1 = converter.coco2bb(coco_dir)
    coco_bbs_v1.sort(key=lambda x: str(x), reverse=True)
    # COCO
    coco_dir = os.path.join(gts_dir, 'coco_format_v2')
    coco_bbs_v2 = converter.coco2bb(coco_dir)
    coco_bbs_v2.sort(key=lambda x: str(x), reverse=True)
    # CVAT
    cvat_dir = os.path.join(gts_dir, 'cvat_format')
    cvat_bbs = converter.cvat2bb(cvat_dir)
    cvat_bbs.sort(key=lambda x: str(x), reverse=True)
    # IMAGENET
    imagenet_dir = os.path.join(gts_dir, 'imagenet_format/Annotations')
    imagenet_bbs = converter.imagenet2bb(imagenet_dir)
    imagenet_bbs.sort(key=lambda x: str(x), reverse=True)
    # LABEL ME
    labelme_dir = os.path.join(gts_dir, 'labelme_format')
    labelme_bbs = converter.labelme2bb(labelme_dir)
    labelme_bbs.sort(key=lambda x: str(x), reverse=True)
    # OPEN IMAGE
    openimage_dir = os.path.join(gts_dir, 'openimages_format')
    openimage_bbs = converter.openimage2bb(openimage_dir, images_dir)
    openimage_bbs.sort(key=lambda x: str(x), reverse=True)
    # VOC PASCAL
    vocpascal_dir = os.path.join(gts_dir, 'pascalvoc_format')
    vocpascal_bbs = converter.vocpascal2bb(vocpascal_dir)
    vocpascal_bbs.sort(key=lambda x: str(x), reverse=True)
    # YOLO
    yolo_annotations_dir = os.path.join(gts_dir, 'yolo_format/obj_train_data')
    yolo_names_file = os.path.join(gts_dir, 'yolo_format/obj.names')
    yolo_bbs = converter.yolo2bb(yolo_annotations_dir,
                                 images_dir,
                                 yolo_names_file,
                                 bb_type=BBType.GROUND_TRUTH)
    yolo_bbs.sort(key=lambda x: str(x), reverse=True)

    assert len(coco_bbs_v1) == len(coco_bbs_v2) == len(cvat_bbs) == len(
        imagenet_bbs) == len(labelme_bbs) == len(openimage_bbs) == len(
            vocpascal_bbs) == len(yolo_bbs)

    for coco_bb_v1, coco_bb_v2, cvat_bb, imagenet_bb, labelme_bb, openimage_bb, vocpascal_bb, yolo_bb in zip(
            coco_bbs_v1, coco_bbs_v2, cvat_bbs, imagenet_bbs, labelme_bbs,
            openimage_bbs, vocpascal_bbs, yolo_bbs):
        assert coco_bb_v1 == coco_bb_v2 == cvat_bb == imagenet_bb == labelme_bb == openimage_bb == vocpascal_bb == yolo_bb