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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138 | #!/usr/bin/env python3
"""
Script to compile evaluation results from multiple methods into a pandas table.
"""
import json
import pandas as pd
from pathlib import Path
BASE_DIR = Path("/root/intelpa-2/cagegaussian")
METHODS = {
"deforming_nerf": BASE_DIR / "existing_methods/deforming_nerf/output",
"frosting": BASE_DIR / "existing_methods/frosting/output",
"games": BASE_DIR / "existing_methods/gaussian_mesh_splatting/output",
"sugar": BASE_DIR / "existing_methods/sugar/output",
"ours": BASE_DIR / "gs3d/output",
}
METRICS = ["SSIM", "PSNR", "LPIPS"]
def discover_scenes():
"""Discover all scene names from existing eval directories."""
scenes = set()
for method_name, output_dir in METHODS.items():
for eval_dir in output_dir.glob("eval_*"):
if eval_dir.is_dir():
scene_name = eval_dir.name.replace("eval_", "")
scenes.add(scene_name)
return sorted(scenes)
def load_results(method_name, output_dir, scene_name):
"""Load results.json for a given method and scene."""
results_path = output_dir / f"eval_{scene_name}" / "results.json"
if not results_path.exists():
return None
with open(results_path, "r") as f:
data = json.load(f)
# The JSON has a nested structure with a method-specific key
# Extract the first (and typically only) entry
if data:
inner_data = next(iter(data.values()))
return inner_data
return None
def compile_results():
"""Compile all results into a pandas DataFrame."""
scenes = discover_scenes()
print(f"Discovered scenes: {scenes}")
rows = []
for method_name, output_dir in METHODS.items():
for scene_name in scenes:
results = load_results(method_name, output_dir, scene_name)
if results:
row = {
"method": method_name,
"scene": scene_name,
}
for metric in METRICS:
row[metric] = results.get(metric)
rows.append(row)
else:
print(f"Warning: No results found for {method_name}/{scene_name}")
df = pd.DataFrame(rows)
return df
def get_best_method(scene_df, metric):
"""Get the best method for a metric (higher is better for SSIM/PSNR, lower for LPIPS)."""
if metric == "LPIPS":
best_idx = scene_df[metric].idxmin()
else:
best_idx = scene_df[metric].idxmax()
return scene_df.loc[best_idx, "method"]
def main():
df = compile_results()
print("\n=== Full Results Table ===")
print(df.to_string(index=False))
# Print per-scene results with best method highlighted
scenes = df["scene"].unique()
for scene in sorted(scenes):
print(f"\n{'='*60}")
print(f"Scene: {scene}")
print("=" * 60)
scene_df = df[df["scene"] == scene].copy()
scene_df = scene_df.set_index("method")[METRICS]
print(scene_df.to_string())
# Find best method for each metric
print("\nBest methods:")
for metric in METRICS:
if metric == "LPIPS":
best_method = scene_df[metric].idxmin()
best_value = scene_df[metric].min()
else:
best_method = scene_df[metric].idxmax()
best_value = scene_df[metric].max()
print(f" {metric}: {best_method} ({best_value:.4f})")
# Compute mean across scenes for each method
print(f"\n{'='*60}")
print("Average Metrics by Method (across all scenes)")
print("=" * 60)
avg_df = df.groupby("method")[METRICS].mean()
print(avg_df.to_string())
# Find best method for each metric on average
print("\nBest methods (average):")
for metric in METRICS:
if metric == "LPIPS":
best_method = avg_df[metric].idxmin()
best_value = avg_df[metric].min()
else:
best_method = avg_df[metric].idxmax()
best_value = avg_df[metric].max()
print(f" {metric}: {best_method} ({best_value:.4f})")
# Save to CSV
output_path = BASE_DIR / "compiled_results_quant_quality.csv"
df.to_csv(output_path, index=False)
print(f"\nResults saved to {output_path}")
return df
if __name__ == "__main__":
main()
|