Skip to content

Commit 97bf74f

Browse files
chyomin06fracape
authored andcommitted
[feature] no cactus option for class-wise evaluation
1 parent d52a4da commit 97bf74f

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

scripts/metrics/compute_overall_map.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@
8686
TMP_ANCH_FILE = "tmp_anch.json"
8787

8888

89-
def compute_overall_mAP(class_name, items):
89+
def compute_overall_mAP(class_name, items, no_cactus=False):
9090
seq_root_names = SEQS_BY_CLASS[class_name]
9191

92+
if no_cactus and class_name == "CLASS-AB":
93+
if "Cactus" in seq_root_names:
94+
seq_root_names.remove("Cactus")
95+
9296
classwise_instances_results = []
9397
classwise_anchor_images = []
9498
classwise_annotation = []

scripts/metrics/gen_mpeg_cttc_csv.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ def generate_csv_classwise_video_map(
150150
metric="AP",
151151
gt_folder="annotations",
152152
nb_operation_points: int = 4,
153+
no_cactus: bool = False,
153154
skip_classwise: bool = False,
154155
):
155156
opts_metrics = {"AP": 0, "AP50": 1, "AP75": 2, "APS": 3, "APM": 4, "APL": 5}
@@ -165,6 +166,10 @@ def generate_csv_classwise_video_map(
165166
## drop columns
166167
output_df.drop(columns=["fps", "num_of_coded_frame"], inplace=True)
167168

169+
if no_cactus:
170+
indices_to_drop = output_df[output_df["Dataset"].str.contains("Cactus")].index
171+
output_df.drop(indices_to_drop, inplace=True)
172+
168173
for seqs_by_class in list_of_classwise_seq:
169174
classwise_name = list(seqs_by_class.keys())[0]
170175
classwise_seqs = list(seqs_by_class.values())[0]
@@ -186,7 +191,7 @@ def generate_csv_classwise_video_map(
186191
), "No evaluation information found in provided result directories..."
187192

188193
if not skip_classwise:
189-
summary = compute_overall_mAP(classwise_name, items)
194+
summary = compute_overall_mAP(classwise_name, items, no_cactus)
190195
maps = summary.values[0][opts_metrics[metric]]
191196
class_wise_maps.append(maps)
192197

@@ -334,6 +339,12 @@ def generate_csv(result_path, seq_list, nb_operation_points):
334339
default=False,
335340
help="Include optional sequences.",
336341
)
342+
parser.add_argument(
343+
"--no-cactus",
344+
action="store_true",
345+
default=False,
346+
help="exclude Cactus sequence for FCM eval",
347+
)
337348

338349
args = parser.parse_args()
339350

@@ -359,6 +370,11 @@ def generate_csv(result_path, seq_list, nb_operation_points):
359370
if args.mode == "VCM":
360371
class_ab["CLASS-AB"].remove("Kimono")
361372
class_ab["CLASS-AB"].remove("Cactus")
373+
else:
374+
assert args.mode == "FCM"
375+
if args.no_cactus is True:
376+
class_ab["CLASS-AB"].remove("Cactus")
377+
362378
class_c = {
363379
"CLASS-C": ["BasketballDrill", "BQMall", "PartyScene", "RaceHorses_832x480"]
364380
}
@@ -400,6 +416,9 @@ def generate_csv(result_path, seq_list, nb_operation_points):
400416
seq_list.remove("Kimono_1920x1080_24")
401417
seq_list.remove("Cactus_1920x1080_50")
402418

419+
if args.mode == "FCM" and args.no_cactus:
420+
seq_list.remove("Cactus_1920x1080_50")
421+
403422
output_df = generate_csv_classwise_video_map(
404423
norm_result_path,
405424
args.dataset_path,
@@ -408,6 +427,7 @@ def generate_csv(result_path, seq_list, nb_operation_points):
408427
metric,
409428
args.gt_folder,
410429
args.nb_operation_points,
430+
args.no_cactus,
411431
args.mode == "VCM", # skip classwise evaluation
412432
)
413433

0 commit comments

Comments
 (0)