Datasets:

Modalities:
Video
Audio
Languages:
English
ArXiv:
License:
File size: 2,641 Bytes
f89df01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os, json
import numpy as np
from sklearn import metrics
from tqdm import tqdm

# --- Utilities ---
def final_auc(data):
    thresholds = [0.05 * i for i in range(21)]
    cious = [np.mean(np.array(data) >= t) for t in thresholds]
    return metrics.auc(thresholds, cious)

def final_ciou(data):
    return np.mean(data) if data else 0.0

def parse_task_flags(annotations):
    flags = {"Single-Sound": False, "Mixed-Sound": False, "Multi-Entity": False, "Off-Screen": False}
    for ann in annotations:
        task = ann["task"]
        if task not in flags:
            raise ValueError(f"Unknown task: {task}")
        flags[task] = True
    return flags


# --- Parameters ---
heatmap_threshold = 0.1
width, height = 640, 360
folder = "AVATAR"
file = "evaluation_results.json"
model = "your_model_name"  # Replace with your model name
data_path = os.path.join("your_heatmap_root", model, folder, file)
benchmark_path = "AVATAR/metadata"  # Replace with your benchmark path



# --- Initialization ---
ciou_by_task = {
    "Total": [],
    "Single-Sound": [],
    "Mixed-Sound": [],
    "Multi-Entity": []
}
off_screen_tn, off_screen_fp = 0, 0


# --- Load Evaluation Results ---
with open(data_path, 'r') as f:
    data = json.load(f)


# --- Process Each Frame ---
for frame_key, result in tqdm(data.items()):
    video_id = "_".join(frame_key.split("_")[:-1])
    frame_num = int(frame_key.split("_")[-1])
    metadata_file = os.path.join(benchmark_path, video_id, f"{frame_num:05d}.json")

    with open(metadata_file, 'r') as f:
        annotations = json.load(f)["annotations"]

    flags = parse_task_flags(annotations)
    ciou = result["cious"][str(heatmap_threshold)]
    ciou_by_task["Total"].append(ciou)

    for task in ["Single-Sound", "Mixed-Sound", "Multi-Entity"]:
        if flags[task]:
            ciou_by_task[task].append(ciou)

    if flags["Off-Screen"]:
        stats = result["pixel_statistics"][str(heatmap_threshold)]
        off_screen_tn += width * height - stats["fp"]
        off_screen_fp += stats["fp"]


# --- Compute Final Metrics ---
summary = {}
for task, values in ciou_by_task.items():
    summary[task] = {
        "ciou": final_ciou(values),
        "auc": final_auc(values)
    }


# --- Print Results ---
print(f"model: {model}, file: {file}\n")

for task in ["Total", "Single-Sound", "Mixed-Sound", "Multi-Entity"]:
    print(f"--- {task.lower()} ---")
    print(f"final ciou: {summary[task]['ciou']:.4f}")
    print(f"final auc : {summary[task]['auc']:.4f}\n")

print("--- off-screen pixel statistics ---")
print("tn pixels \t fp pixels")
print(f"{off_screen_tn} \t {off_screen_fp}")