Exemplo n.º 1
0
    if map_mode == 0 or map_mode == 1:
        print("Load model.")
        ssd = SSD(confidence=confidence, nms_iou=nms_iou)
        print("Load model done.")

        print("Get predict result.")
        for image_id in tqdm(image_ids):
            image_path = os.path.join(
                VOCdevkit_path, "VOC2007/JPEGImages/" + image_id + ".jpg")
            image = Image.open(image_path)
            if map_vis:
                image.save(
                    os.path.join(map_out_path,
                                 "images-optional/" + image_id + ".jpg"))
            ssd.get_map_txt(image_id, image, class_names, map_out_path)
        print("Get predict result done.")

    if map_mode == 0 or map_mode == 2:
        print("Get ground truth result.")
        for image_id in tqdm(image_ids):
            with open(
                    os.path.join(map_out_path,
                                 "ground-truth/" + image_id + ".txt"),
                    "w") as new_f:
                root = ET.parse(
                    os.path.join(VOCdevkit_path, "VOC2007/Annotations/" +
                                 image_id + ".xml")).getroot()
                for obj in root.findall('object'):
                    difficult_flag = False
                    if obj.find('difficult') != None: