MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / parse_annotations

Function parse_annotations

samples/python/efficientdet/compare_tf.py:43–62  ·  view source on GitHub ↗
(annotations_path)

Source from the content-addressed store, hash-verified

41
42
43def 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
65def compare_images(tf_images, tf_detections, trt_images, trt_detections, output_dir, annotations_path, labels_path):

Callers 1

compare_imagesFunction · 0.70

Calls 3

loadMethod · 0.45
keysMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected