Skip to content

Commit 307be81

Browse files
committed
[chore] Enforce metrics output as per dataset dict
1 parent fe01688 commit 307be81

File tree

2 files changed

+147
-254
lines changed

2 files changed

+147
-254
lines changed

scripts/metrics/compute_overall_map.py

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,53 +58,51 @@
5858

5959
SEQS_BY_CLASS = {
6060
CLASSES[0]: [
61-
"Traffic",
62-
"Kimono",
63-
"ParkScene",
64-
"Cactus",
65-
"BasketballDrive",
66-
"BQTerrace",
61+
"Traffic_2560x1600_30",
62+
"Kimono_1920x1080_24",
63+
"ParkScene_1920x1080_24",
64+
"Cactus_1920x1080_50",
65+
"BasketballDrive_1920x1080_50",
66+
"BQTerrace_1920x1080_60",
6767
],
68-
CLASSES[1]: ["BasketballDrill", "BQMall", "PartyScene", "RaceHorses_832x480"],
69-
CLASSES[2]: ["BasketballPass", "BQSquare", "BlowingBubbles", "RaceHorses"],
70-
CLASSES[3]: ["Traffic", "BQTerrace"],
68+
CLASSES[1]: ["BasketballDrill_832x480_50", "BQMall_832x480_60", "PartyScene_832x480_50", "RaceHorses_832x480_832x480_30"],
69+
CLASSES[2]: ["BasketballPass_416x240_50", "BQSquare_416x240_60", "BlowingBubbles_416x240_50", "RaceHorses_416x240_30"],
70+
CLASSES[3]: ["ns_Traffic_2560x1600_30", "ns_BQTerrace_1920x1080_60"],
7171
}
7272

7373
SEQUENCE_TO_OFFSET = {
74-
"Traffic": 10000,
75-
"Kimono": 20000,
76-
"ParkScene": 30000,
77-
"Cactus": 40000,
78-
"BasketballDrive": 50000,
79-
"BQTerrace": 60000,
80-
"BasketballDrill": 70000,
81-
"BQMall": 80000,
82-
"PartyScene": 90000,
83-
"RaceHorses_832x480": 100000,
84-
"BasketballPass": 110000,
85-
"BQSquare": 120000,
86-
"BlowingBubbles": 130000,
87-
"RaceHorses": 140000,
74+
"Traffic_2560x1600_30": 10000,
75+
"Kimono_1920x1080_24": 20000,
76+
"ParkScene_1920x1080_24": 30000,
77+
"Cactus_1920x1080_50": 40000,
78+
"BasketballDrive_1920x1080_50": 50000,
79+
"BQTerrace_1920x1080_60": 60000,
80+
"BasketballDrill_832x480_50": 70000,
81+
"BQMall_832x480_60": 80000,
82+
"PartyScene_832x480_50": 90000,
83+
"RaceHorses_832x480_30": 100000,
84+
"BasketballPass_416x240_50": 110000,
85+
"BQSquare_416x240_60": 120000,
86+
"BlowingBubbles_416x240_50": 130000,
87+
"RaceHorses_416x240_30": 140000,
8888
}
8989

9090
TMP_EVAL_FILE = "tmp_eval.json"
9191
TMP_ANCH_FILE = "tmp_anch.json"
9292

93+
NS_SEQ_PREFIX = "ns_" # Prefix of non-scaled sequences
9394

94-
def compute_overall_mAP(class_name, items, no_cactus=False):
95-
seq_root_names = SEQS_BY_CLASS[class_name]
96-
97-
if no_cactus and class_name == "CLASS-AB":
98-
if "Cactus" in seq_root_names:
99-
seq_root_names.remove("Cactus")
95+
def compute_overall_mAP(seq_root_names, items):
10096

10197
classwise_instances_results = []
10298
classwise_anchor_images = []
10399
classwise_annotation = []
104100
categories = None
105101
annotation_id = 0
106102
for e, (item, root_name) in enumerate(zip(items, seq_root_names)):
107-
assert root_name in item[utils.SEQ_NAME_KEY]
103+
assert root_name in item[utils.SEQ_NAME_KEY], f"Not found {root_name} in {item[utils.SEQ_NAME_KEY]} {utils.SEQ_NAME_KEY}"
104+
105+
root_name = root_name.replace(NS_SEQ_PREFIX, "")
108106

109107
seq_img_id_offset = SEQUENCE_TO_OFFSET[root_name]
110108

@@ -251,7 +249,7 @@ def __init__(self):
251249
len(items) > 0
252250
), "Nothing relevant information found from given directories..."
253251

254-
summary = compute_overall_mAP(args.class_to_compute, items)
252+
summary = compute_overall_mAP(SEQS_BY_CLASS[args.class_to_compute], items)
255253

256254
writer.writerow([f"{q}", f"{summary['AP'][0]:.4f}"])
257255
print(f"{'=' * 10} FINAL OVERALL mAP SUMMARY {'=' * 10}")

0 commit comments

Comments
 (0)