(annotations_path)
| 41 | |
| 42 | |
| 43 | def parse_annotations(annotations_path): |
| 44 | annotations = {} |
| 45 | if annotations_path and os.path.exists(annotations_path): |
| 46 | with open(annotations_path) as f: |
| 47 | ann_json = json.load(f) |
| 48 | for ann in ann_json["annotations"]: |
| 49 | img_id = ann["image_id"] |
| 50 | if img_id not in annotations.keys(): |
| 51 | annotations[img_id] = [] |
| 52 | annotations[img_id].append( |
| 53 | { |
| 54 | "ymin": ann["bbox"][1], |
| 55 | "xmin": ann["bbox"][0], |
| 56 | "ymax": ann["bbox"][1] + ann["bbox"][3], |
| 57 | "xmax": ann["bbox"][0] + ann["bbox"][2], |
| 58 | "score": -1, |
| 59 | "class": ann["category_id"] - 1, |
| 60 | } |
| 61 | ) |
| 62 | return annotations |
| 63 | |
| 64 | |
| 65 | def compare_images(tf_images, tf_detections, trt_images, trt_detections, output_dir, annotations_path, labels_path): |
no test coverage detected