File size: 2,706 Bytes
23e73f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import json
import pandas as pd

def main():
    outputs_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "outputs"))
    data = []

    for folder in os.listdir(outputs_dir):
        method_dir = os.path.join(outputs_dir, folder)
        if not os.path.isdir(method_dir) or folder == "pathology_archive":
            continue

        # 优先寻找批量管线的终点文件
        metrics_file = os.path.join(method_dir, "metrics_test_iter30000.json")
        if not os.path.exists(metrics_file):
            metrics_file = os.path.join(method_dir, "metrics.json")
        
        train_metrics_file = os.path.join(method_dir, "metrics_train_iter30000.json")
        physics_file = os.path.join(method_dir, "offline_physics_30000.json")

        row = {"Method": folder.split('_')[0], "Scene": folder.split('_')[1] if '_' in folder else "unknown"}

        if os.path.exists(metrics_file):
            with open(metrics_file, 'r') as f:
                m = json.load(f)
                row["PSNR_Test"] = m.get("photometric", {}).get("PSNR", 0)
                row["SSIM"] = m.get("photometric", {}).get("SSIM", 0)
                row["Prior"] = m.get("prior_type", "none")
                row["Flags"] = len(m.get("pathology_flags", []))
                
                # 提取 Train PSNR 并计算你的核心主张:Delta PSNR
                if os.path.exists(train_metrics_file):
                    with open(train_metrics_file, 'r') as tf:
                        tm = json.load(tf)
                        row["PSNR_Train"] = tm.get("photometric", {}).get("PSNR", 0)
                        row["Delta_PSNR"] = row["PSNR_Train"] - row["PSNR_Test"]

        if os.path.exists(physics_file):
            with open(physics_file, 'r') as f:
                p = json.load(f)
                # 修正了旧版错误的字典查找,完美对齐新数据
                row["Gini"] = p.get("spatial_gini", 0)
                row["SH_Ratio"] = p.get("sh_energy_ratio", 0)
                row["Condition"] = p.get("scale_condition_mean", 0)
                row["Billboard_Bias"] = p.get("billboard_bias_ratio", 0)
                
        if len(row) > 2:
            data.append(row)

    if not data:
        return

    df = pd.DataFrame(data).round(3)
    csv_path = os.path.join(outputs_dir, "grand_leaderboard.csv")
    df.to_csv(csv_path, index=False)

    latex_str = df.to_latex(index=False, float_format="%.3f")
    with open(os.path.join(outputs_dir, "grand_leaderboard.tex"), "w") as f:
        f.write(latex_str)
    
    print(f"📊 [GrandTable] 大榜单生成完毕!共收录 {len(data)} 个模型数据。")

if __name__ == "__main__":
    main()