Skip to content

Commit 1ec72d9

Browse files
chyomin06fracape
authored andcommitted
[fix] bug - sequence name differently used for between FCM and VCM
1 parent b3b4dbe commit 1ec72d9

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

utils/gen_mpeg_cttc_csv.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from os.path import join
3939
from pathlib import Path
4040

41+
import numpy as np
4142
import pandas as pd
4243
from compute_overall_map import compute_overall_mAP
4344
from compute_overall_mot import compute_overall_mota
@@ -55,11 +56,17 @@
5556

5657
def read_df_rec(path, seq_list, nb_operation_points, fn_regex=r"summary.csv"):
5758
summary_csvs = [f for f in iglob(join(path, "**", fn_regex), recursive=True)]
59+
5860
if nb_operation_points > 0:
59-
for sequence in seq_list:
61+
seq_names = [
62+
file_path.split(path)[1].split("/")[0] for file_path in summary_csvs
63+
]
64+
unique_seq_names = list(np.unique(seq_names))
65+
for sequence in unique_seq_names:
6066
assert (
6167
len([f for f in summary_csvs if sequence in f]) == nb_operation_points
6268
), f"Did not find {nb_operation_points} results for {sequence}"
69+
6370
return pd.concat(
6471
(pd.read_csv(f) for f in summary_csvs),
6572
ignore_index=True,
@@ -350,6 +357,8 @@ def generate_csv(result_path, seq_list, nb_operation_points):
350357
and args.dataset_name.lower() in Path(args.result_path).name.lower()
351358
), "Please check correspondance between input dataset name and result directory"
352359

360+
norm_result_path = os.path.normpath(args.result_path) + "/"
361+
353362
if args.dataset_name == "SFU":
354363
metric = args.metric
355364
class_ab = {
@@ -407,7 +416,7 @@ def generate_csv(result_path, seq_list, nb_operation_points):
407416
seq_list.remove("Cactus_1920x1080_50")
408417

409418
output_df = generate_csv_classwise_video_map(
410-
args.result_path,
419+
norm_result_path,
411420
args.dataset_path,
412421
classes,
413422
seq_list,
@@ -426,13 +435,13 @@ def generate_csv(result_path, seq_list, nb_operation_points):
426435
)
427436
elif args.dataset_name == "OIV6":
428437
output_df = generate_csv(
429-
args.result_path, ["MPEGOIV6"], args.nb_operation_points
438+
norm_result_path, ["MPEGOIV6"], args.nb_operation_points
430439
)
431440
elif args.dataset_name == "TVD":
432441
if args.mode == "FCM":
433442
tvd_all = {"TVD": ["TVD-01", "TVD-02", "TVD-03"]}
434443
output_df = generate_csv_classwise_video_mota(
435-
args.result_path,
444+
norm_result_path,
436445
args.dataset_path,
437446
[tvd_all],
438447
args.nb_operation_points,
@@ -450,7 +459,7 @@ def generate_csv(result_path, seq_list, nb_operation_points):
450459
]
451460
}
452461

453-
results_df = read_df_rec(args.result_path)
462+
results_df = read_df_rec(norm_result_path)
454463
results_df = results_df.sort_values(
455464
by=["Dataset", "qp"], ascending=[True, True]
456465
)
@@ -475,7 +484,7 @@ def generate_csv(result_path, seq_list, nb_operation_points):
475484
hieve_1080p = {"HIEVE-1080P": ["mpeg-hieve-13", "mpeg-hieve-16"]}
476485
hieve_720p = {"HIEVE-720P": ["mpeg-hieve-2", "mpeg-hieve-17", "mpeg-hieve-18"]}
477486
output_df = generate_csv_classwise_video_mota(
478-
args.result_path,
487+
norm_result_path,
479488
args.dataset_path,
480489
[hieve_1080p, hieve_720p],
481490
args.nb_operation_points,
@@ -498,7 +507,7 @@ def generate_csv(result_path, seq_list, nb_operation_points):
498507
raise NotImplementedError
499508

500509
# save
501-
final_csv_path = os.path.join(args.result_path, f"final_{args.dataset_name}.csv")
510+
final_csv_path = os.path.join(norm_result_path, f"final_{args.dataset_name}.csv")
502511
output_df.to_csv(final_csv_path, sep=",", encoding="utf-8")
503512
print(output_df)
504513
print(f"Final CSV Saved at: {final_csv_path}")

0 commit comments

Comments
 (0)