Add figures (155 files)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- figures/_fonts/STIX-Two-Text-Regular.ttf +0 -0
- figures/alignment/alignment_reward.pdf +0 -0
- figures/alignment/alignment_reward.png +3 -0
- figures/alignment/alignment_vqa.pdf +0 -0
- figures/alignment/alignment_vqa.png +3 -0
- figures/alignment/plot_alignment_correlation.py +489 -0
- figures/alignment/plot_reward_alignment.py +402 -0
- figures/alignment/reward_alignment_pairgrid.pdf +0 -0
- figures/benchmark/benchmark_overview.pdf +0 -0
- figures/benchmark/benchmark_overview.png +3 -0
- figures/benchmark/plot_benchmark_overview.py +252 -0
- figures/gemini_figures/_gen.py +62 -0
- figures/gemini_figures/_gen2.py +65 -0
- figures/gemini_figures/_gen_p2.py +66 -0
- figures/gemini_figures/_gen_p3.py +66 -0
- figures/gemini_figures/attribute.png +3 -0
- figures/gemini_figures/attribute_p2.png +3 -0
- figures/gemini_figures/attribute_p3.png +3 -0
- figures/gemini_figures/attribute_v2.png +3 -0
- figures/gemini_figures/balance.png +3 -0
- figures/gemini_figures/balance_p2.png +3 -0
- figures/gemini_figures/balance_p3.png +3 -0
- figures/gemini_figures/balance_v2.png +3 -0
- figures/gemini_figures/entity.png +3 -0
- figures/gemini_figures/entity_p2.png +3 -0
- figures/gemini_figures/entity_p3.png +3 -0
- figures/gemini_figures/entity_v2.png +3 -0
- figures/gemini_figures/origin.png +3 -0
- figures/gemini_figures/origin_p2.png +3 -0
- figures/gemini_figures/origin_p3.png +3 -0
- figures/gemini_figures/origin_v2.png +3 -0
- figures/gemini_figures/prompt.json +7 -0
- figures/gemini_figures/prompt2.json +7 -0
- figures/gemini_figures/prompt3.json +7 -0
- figures/gemini_figures/relation.png +3 -0
- figures/gemini_figures/relation_p2.png +3 -0
- figures/gemini_figures/relation_p3.png +3 -0
- figures/gemini_figures/relation_v2.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/flux2_base.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/flux2_lora_clip.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/flux2_lora_hpsv3.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/flux2_lora_unified_9b.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/flux2_lora_vqa_balance.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/zimage_base.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/zimage_lora_clip.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/zimage_lora_hpsv3.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/zimage_lora_unified_9b.png +3 -0
- figures/portrait_compare/01_aesthetic_photo/zimage_lora_vqa_balance_30st.png +3 -0
- figures/portrait_compare/02_art_nouveau/flux2_base.png +3 -0
- figures/portrait_compare/02_art_nouveau/flux2_lora_clip.png +3 -0
figures/_fonts/STIX-Two-Text-Regular.ttf
ADDED
|
Binary file (36.8 kB). View file
|
|
|
figures/alignment/alignment_reward.pdf
ADDED
|
Binary file (58.6 kB). View file
|
|
|
figures/alignment/alignment_reward.png
ADDED
|
Git LFS Details
|
figures/alignment/alignment_vqa.pdf
ADDED
|
Binary file (42.3 kB). View file
|
|
|
figures/alignment/alignment_vqa.png
ADDED
|
Git LFS Details
|
figures/alignment/plot_alignment_correlation.py
ADDED
|
@@ -0,0 +1,489 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Per-benchmark overlay: rewards vs MLLM_Judge in one panel.
|
| 2 |
+
|
| 3 |
+
Both axes are min-max normalised to [0,1] per benchmark so all panels share
|
| 4 |
+
identical [0,1] x [0,1] axes and a perfect aligner sits on the diagonal.
|
| 5 |
+
|
| 6 |
+
Two figures are produced:
|
| 7 |
+
Figure 1 (traditional rewards): CLIPScore, HPSv3, PickScore, UnifiedReward-9B, VQAScore-9B
|
| 8 |
+
Figure 2 (VQA family): VQAScore-binary-9B, VQAScore-9B
|
| 9 |
+
|
| 10 |
+
Each figure is a single row of 4 benchmark panels:
|
| 11 |
+
longbencht2i, t2icompbench, t2icorebench_composition, tiifbench.
|
| 12 |
+
"""
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
import re
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import matplotlib.colors as mcolors
|
| 19 |
+
import matplotlib.font_manager as fm
|
| 20 |
+
import matplotlib.pyplot as plt
|
| 21 |
+
import numpy as np
|
| 22 |
+
import pandas as pd
|
| 23 |
+
from matplotlib.offsetbox import AnchoredOffsetbox, HPacker, TextArea, VPacker
|
| 24 |
+
from matplotlib.patches import Polygon
|
| 25 |
+
from scipy.stats import pearsonr
|
| 26 |
+
|
| 27 |
+
ROOT = Path(__file__).resolve().parent
|
| 28 |
+
SRC = ROOT.parent.parent / "sheet_exports" / "alignment.txt"
|
| 29 |
+
|
| 30 |
+
# Register and select the shared STIX Two Text typeface.
|
| 31 |
+
_FONT = ROOT.parent / "_fonts" / "STIX-Two-Text-Regular.ttf"
|
| 32 |
+
fm.fontManager.addfont(str(_FONT))
|
| 33 |
+
_FAMILY = fm.FontProperties(fname=str(_FONT)).get_name()
|
| 34 |
+
plt.rcParams.update({
|
| 35 |
+
"font.family": _FAMILY,
|
| 36 |
+
"font.serif": [_FAMILY, "DejaVu Serif"],
|
| 37 |
+
"mathtext.fontset": "stix",
|
| 38 |
+
"axes.unicode_minus": False,
|
| 39 |
+
})
|
| 40 |
+
JUDGE_COL = "MLLM_Judge"
|
| 41 |
+
|
| 42 |
+
BENCHMARKS = ["t2icompbench", "tiifbench", "spatialgeneval", "t2icorebench_composition", "longbencht2i"]
|
| 43 |
+
BENCHMARK_DISPLAY = {
|
| 44 |
+
"t2icompbench": "T2I-CompBench",
|
| 45 |
+
"tiifbench": "TIIFBench",
|
| 46 |
+
"t2icorebench_composition": "T2I-CoReBench-\nComposition",
|
| 47 |
+
"longbencht2i": "LongBench-T2I",
|
| 48 |
+
"spatialgeneval": "SpatialGenEval",
|
| 49 |
+
}
|
| 50 |
+
GROUPS = {
|
| 51 |
+
"rewards_classic": ["CLIPScore", "HPSv3", "PickScore", "ImageReward",
|
| 52 |
+
"UnifiedReward-9B", "VQAScore-9B"],
|
| 53 |
+
"rewards_vqa": ["VQAScore-binary-9B", "VQAScore-Gemma-4-E4B", "VQAScore-9B"],
|
| 54 |
+
}
|
| 55 |
+
# Google brand colors (+ Google purple for the 5th slot in the classic group)
|
| 56 |
+
GOOGLE_BLUE = "#4285F4"
|
| 57 |
+
GOOGLE_RED = "#EA4335"
|
| 58 |
+
GOOGLE_YELLOW = "#FBBC05"
|
| 59 |
+
GOOGLE_GREEN = "#34A853"
|
| 60 |
+
GOOGLE_PURPLE = "#A142F4"
|
| 61 |
+
# VQAScore-9B kept blue across both figures so the classic figure avoids a
|
| 62 |
+
# collision with CLIPScore (also red); the VQA-family figure uses pure
|
| 63 |
+
# Google brand colors (blue + red).
|
| 64 |
+
GOOGLE_TEAL = "#00ACC1"
|
| 65 |
+
GOOGLE_ORANGE = "#FF9800"
|
| 66 |
+
COLORS = {
|
| 67 |
+
"CLIPScore": GOOGLE_RED,
|
| 68 |
+
"HPSv3": GOOGLE_YELLOW,
|
| 69 |
+
"PickScore": GOOGLE_GREEN,
|
| 70 |
+
"ImageReward": GOOGLE_TEAL,
|
| 71 |
+
"UnifiedReward-9B": GOOGLE_PURPLE,
|
| 72 |
+
"VQAScore-Gemma-4-E4B": GOOGLE_ORANGE,
|
| 73 |
+
"VQAScore-9B": GOOGLE_BLUE,
|
| 74 |
+
"VQAScore-binary-9B": GOOGLE_RED,
|
| 75 |
+
}
|
| 76 |
+
# Distinct marker per reward to disambiguate beyond color.
|
| 77 |
+
MARKERS = {
|
| 78 |
+
"CLIPScore": "s", # square
|
| 79 |
+
"HPSv3": "P", # filled plus
|
| 80 |
+
"PickScore": "D", # diamond
|
| 81 |
+
"ImageReward": "*", # star
|
| 82 |
+
"UnifiedReward-9B": "^", # triangle up
|
| 83 |
+
"VQAScore-Gemma-4-E4B": "h", # hexagon
|
| 84 |
+
"VQAScore-9B": "o", # circle (highlight)
|
| 85 |
+
"VQAScore-binary-9B": "X", # filled x
|
| 86 |
+
}
|
| 87 |
+
# Per-marker visual scaling (some markers look smaller at the same area).
|
| 88 |
+
MARKER_SCALE = {
|
| 89 |
+
"s": 1.0,
|
| 90 |
+
"P": 1.45, # plus needs more area to read clearly
|
| 91 |
+
"D": 0.85,
|
| 92 |
+
"*": 1.55, # star looks smaller at same area
|
| 93 |
+
"^": 1.35, # triangle reads smaller too
|
| 94 |
+
"h": 1.05, # hexagon
|
| 95 |
+
"o": 1.0,
|
| 96 |
+
"X": 1.15,
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
# ---------------------------------------------------------------------------
|
| 101 |
+
# 视觉调节区 STYLE: 改下面这些数字就能调节图的字号 / 线宽 / 点大小 / 间距等
|
| 102 |
+
# ---------------------------------------------------------------------------
|
| 103 |
+
STYLE = {
|
| 104 |
+
# ---- 整张图的画布尺寸 (英寸) ----
|
| 105 |
+
# panel_w / panel_h 是单个 panel 的宽 / 高 (一共 2 行 × 3 列).
|
| 106 |
+
# right_pad 是图右边留给 legend 的额外空白宽度 (越大空白越多).
|
| 107 |
+
"panel_w": 3.8, # 单个 panel 宽
|
| 108 |
+
"panel_h": 2.5, # 单个 panel 高 (想整体拉高就调这个)
|
| 109 |
+
"right_pad": 2.6, # 右侧给 legend 留的空白宽度 (英寸)
|
| 110 |
+
|
| 111 |
+
# ---- 散点 panel 内, 右下角 benchmark 名字框 (T2I-CompBench 等) ----
|
| 112 |
+
"bench_label_fontsize": 15, # benchmark 名字框文字字号
|
| 113 |
+
"bench_label_x": 0.96, # 名字框水平位置 (1 = panel 最右)
|
| 114 |
+
"bench_label_y": 0.07, # 名字框垂直位置 (0 = panel 最下)
|
| 115 |
+
|
| 116 |
+
# ---- 散点 panel 坐标轴 ----
|
| 117 |
+
"panel_xlabel_fontsize": 16, # "Reward" 横坐标标题字号
|
| 118 |
+
"panel_ylabel_fontsize": 16, # "Score" 纵坐标标题字号
|
| 119 |
+
"panel_tick_fontsize": 14, # 散点 panel 刻度数字 (0.0 / 0.5 / 1.0) 字号
|
| 120 |
+
|
| 121 |
+
# ---- 散点 panel 内的散点和拟合线 ----
|
| 122 |
+
"scatter_highlight_line_width": 4, # 高亮 reward (VQAScore-9B) 拟合线粗
|
| 123 |
+
"scatter_highlight_point_size": 40, # 高亮 reward 散点大小
|
| 124 |
+
"scatter_other_line_width": 1.5, # 其他 reward 拟合���粗
|
| 125 |
+
"scatter_other_point_size": 32, # 其他 reward 散点大小
|
| 126 |
+
|
| 127 |
+
# ---- 中间下排的 r-vs-benchmark 折线图 ----
|
| 128 |
+
"line_xlabel_fontsize": 16, # "Benchmark" 横坐标标题字号
|
| 129 |
+
"line_ylabel_fontsize": 16, # "Pearson r" 纵坐标标题字号
|
| 130 |
+
"line_tick_fontsize": 14, # 折线图刻度数字字号
|
| 131 |
+
"line_highlight_line_width": 3, # 高亮 reward 折线粗细
|
| 132 |
+
"line_highlight_marker_size": 10, # 高亮 reward 折线上的点大小
|
| 133 |
+
"line_other_line_width": 2, # 其他 reward 折线粗细
|
| 134 |
+
"line_other_marker_size": 8, # 其他 reward 折线上的点大小
|
| 135 |
+
|
| 136 |
+
# ---- 右侧 legend (CLIPScore / HPSv3 / ... 那一列) ----
|
| 137 |
+
"legend_fontsize": 15, # legend 文字字号
|
| 138 |
+
"legend_marker_size": 12, # legend 上点的大小 (会按 MARKER_SCALE 再缩放)
|
| 139 |
+
"legend_highlight_line_width": 3, # legend 上高亮 reward 的小线段粗细
|
| 140 |
+
"legend_other_line_width": 2.4, # legend 上其他 reward 的小线段粗细
|
| 141 |
+
"legend_handle_len": 2.4, # legend 上小线段的长度
|
| 142 |
+
"legend_label_spacing": 1.4, # legend 各项之间的垂直距离 (越大越松)
|
| 143 |
+
"legend_x_offset": 0.2, # legend 相对 panel 区域右侧的水平偏移 (英寸)
|
| 144 |
+
|
| 145 |
+
# ---- 中间下排折线图的 "纵坐标跳跃" (broken y-axis) ----
|
| 146 |
+
# 折线图会被切成上下两段, 中间用斜线断开. 两张图 (reward / vqa) 的范围不一样,
|
| 147 |
+
# 所以下面分成两个子字典. main() 里给每张图传 split_key="reward" / "vqa".
|
| 148 |
+
# 各字段含义:
|
| 149 |
+
# low_min / low_max : 下半段纵坐标的下界 / 上界
|
| 150 |
+
# high_min / high_max: 上半段纵坐标的下界 / 上界
|
| 151 |
+
# height_ratio : (上半高度, 下半高度) 比例 — 写成跟 range 比例一致
|
| 152 |
+
# 画出来上下视觉密度就一样; 上半比下半大就是放大上半段
|
| 153 |
+
# hspace : 上下两段之间的间隙 (越大越分开)
|
| 154 |
+
# break_size : 中间斜线小标记的大小 (axes 比例)
|
| 155 |
+
# ylabel_x : "r" 标题相对 axes 的水平偏移 (越负越靠左)
|
| 156 |
+
"line_split": {
|
| 157 |
+
# alignment_reward 用: 上 0~1, 下 -1~-0.5 (中间 -0.5~0 被截掉)
|
| 158 |
+
"reward": {
|
| 159 |
+
"low_min": -1.0,
|
| 160 |
+
"low_max": -0.4,
|
| 161 |
+
"high_min": 0.1,
|
| 162 |
+
"high_max": 1.1,
|
| 163 |
+
"height_ratio": (2.5, 1.0),
|
| 164 |
+
"hspace": 0.1,
|
| 165 |
+
"break_size": 0.02,
|
| 166 |
+
"ylabel_x": -0.13,
|
| 167 |
+
},
|
| 168 |
+
# alignment_vqa 用: 上 0.95~1.0, 下 0.7~0.8 (中间 0.8~0.95 被截掉)
|
| 169 |
+
"vqa": {
|
| 170 |
+
"low_min": 0.7,
|
| 171 |
+
"low_max": 0.8,
|
| 172 |
+
"high_min": 0.95,
|
| 173 |
+
"high_max": 1.0,
|
| 174 |
+
"height_ratio": (3, 1.0),
|
| 175 |
+
"hspace": 0.2,
|
| 176 |
+
"break_size": 0.02,
|
| 177 |
+
"ylabel_x": -0.13,
|
| 178 |
+
},
|
| 179 |
+
},
|
| 180 |
+
}
|
| 181 |
+
# ---------------------------------------------------------------------------
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def parse_sections(path: Path) -> dict[str, pd.DataFrame]:
|
| 185 |
+
text = path.read_text()
|
| 186 |
+
sections: dict[str, pd.DataFrame] = {}
|
| 187 |
+
for match in re.finditer(r"=== (\S+) ===\n(.*?)(?=\n=== |\Z)", text, re.DOTALL):
|
| 188 |
+
name = match.group(1)
|
| 189 |
+
body = match.group(2).strip().splitlines()
|
| 190 |
+
header = body[0].split("\t")
|
| 191 |
+
rows = [line.split("\t") for line in body[1:] if line.strip()]
|
| 192 |
+
df = pd.DataFrame(rows, columns=header).set_index("Model")
|
| 193 |
+
df = df.apply(pd.to_numeric, errors="coerce")
|
| 194 |
+
sections[name] = df
|
| 195 |
+
return sections
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def lighten(color, amount: float = 0.6):
|
| 199 |
+
"""Mix toward white. amount=0 -> original, amount=1 -> white."""
|
| 200 |
+
r, g, b = mcolors.to_rgb(color)
|
| 201 |
+
return (r + (1 - r) * amount, g + (1 - g) * amount, b + (1 - b) * amount)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def minmax(x: np.ndarray) -> np.ndarray | None:
|
| 205 |
+
if np.nanstd(x) == 0:
|
| 206 |
+
return None
|
| 207 |
+
return (x - np.nanmin(x)) / (np.nanmax(x) - np.nanmin(x))
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
HIGHLIGHT = "VQAScore-9B"
|
| 211 |
+
|
| 212 |
+
# Display label override (data column name → legend label).
|
| 213 |
+
DISPLAY_LABEL = {
|
| 214 |
+
"VQAScore-binary-9B": "VQAScore-Binary",
|
| 215 |
+
"VQAScore-Gemma-4-E4B": "VQAScore-Gemma",
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
def display_name(col: str) -> str:
|
| 220 |
+
name = DISPLAY_LABEL.get(col, col)
|
| 221 |
+
return re.sub(r"-\d+B$", "", name)
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def _draw_pearson_lines(ax, xs_idx: np.ndarray, rewards: list[str],
|
| 225 |
+
rho_by_bench: dict[str, dict[str, float]]) -> None:
|
| 226 |
+
"""Draw the per-reward Pearson r line series onto a single axes."""
|
| 227 |
+
for col in rewards:
|
| 228 |
+
ys = [rho_by_bench.get(b, {}).get(col, np.nan) for b in BENCHMARKS]
|
| 229 |
+
is_hi = col == HIGHLIGHT
|
| 230 |
+
base = COLORS[col]
|
| 231 |
+
if is_hi:
|
| 232 |
+
line_color = base
|
| 233 |
+
marker_face = lighten(base, 0.30)
|
| 234 |
+
marker_edge = base
|
| 235 |
+
lw = STYLE["line_highlight_line_width"]
|
| 236 |
+
ms = STYLE["line_highlight_marker_size"]
|
| 237 |
+
else:
|
| 238 |
+
line_color = (*lighten(base, 0.40), 0.75)
|
| 239 |
+
marker_face = (*lighten(base, 0.60), 0.60)
|
| 240 |
+
marker_edge = "white"
|
| 241 |
+
lw = STYLE["line_other_line_width"]
|
| 242 |
+
ms = STYLE["line_other_marker_size"]
|
| 243 |
+
ax.plot(xs_idx, ys, color=line_color, lw=lw,
|
| 244 |
+
marker=MARKERS[col],
|
| 245 |
+
markersize=ms * (MARKER_SCALE[MARKERS[col]] ** 0.5),
|
| 246 |
+
markerfacecolor=marker_face, markeredgecolor=marker_edge,
|
| 247 |
+
markeredgewidth=0.6, zorder=5 if is_hi else 3)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def plot_group(sections: dict[str, pd.DataFrame], rewards: list[str], out_stem: Path,
|
| 251 |
+
legend_labels: dict[str, str] | None = None,
|
| 252 |
+
split_key: str | None = None) -> None:
|
| 253 |
+
"""split_key: 如果传 "reward" / "vqa" 这种 STYLE['line_split'] 里的 key,
|
| 254 |
+
就启用 broken y-axis 并用对应那一组数值; 不传 (None) 就不分裂."""
|
| 255 |
+
|
| 256 |
+
split_y = split_key is not None
|
| 257 |
+
split_cfg = STYLE["line_split"][split_key] if split_y else {}
|
| 258 |
+
|
| 259 |
+
def split(key):
|
| 260 |
+
return split_cfg[key]
|
| 261 |
+
|
| 262 |
+
# Layout: 2 rows × 3 cols. Row 0 = first 3 benchmarks. Row 1 = [bench3,
|
| 263 |
+
# r-vs-benchmark line plot, bench4]. So the middle of row 2 carries the
|
| 264 |
+
# cross-benchmark r summary instead of a benchmark scatter panel.
|
| 265 |
+
panels_w = STYLE["panel_w"] * 3
|
| 266 |
+
right_pad = STYLE["right_pad"]
|
| 267 |
+
fig, axes = plt.subplots(2, 3,
|
| 268 |
+
figsize=(panels_w + right_pad, STYLE["panel_h"] * 2))
|
| 269 |
+
panel_positions = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 2)]
|
| 270 |
+
benchmark_axes = [axes[r, c] for r, c in panel_positions]
|
| 271 |
+
line_ax = axes[1, 1]
|
| 272 |
+
_stair_polygons: list[tuple] = [] # (top_packer, bot_packer, polygon, ax)
|
| 273 |
+
rho_by_bench: dict[str, dict[str, float]] = {}
|
| 274 |
+
|
| 275 |
+
for ax, bench in zip(benchmark_axes, BENCHMARKS):
|
| 276 |
+
df = sections[bench]
|
| 277 |
+
judge = df[JUDGE_COL].values
|
| 278 |
+
y = minmax(judge)
|
| 279 |
+
if y is None:
|
| 280 |
+
ax.text(0.5, 0.5, "judge has no variance", transform=ax.transAxes,
|
| 281 |
+
ha="center", va="center", color="gray")
|
| 282 |
+
ax.text(STYLE["bench_label_x"], STYLE["bench_label_y"],
|
| 283 |
+
BENCHMARK_DISPLAY[bench], transform=ax.transAxes,
|
| 284 |
+
ha="right", va="bottom",
|
| 285 |
+
fontsize=STYLE["bench_label_fontsize"],
|
| 286 |
+
bbox=dict(boxstyle="round,pad=0.32", facecolor="white",
|
| 287 |
+
edgecolor="0.7", linewidth=0.8, alpha=0.9))
|
| 288 |
+
continue
|
| 289 |
+
|
| 290 |
+
# Plot non-highlight rewards first (lower zorder, lighter), then the
|
| 291 |
+
# highlight reward on top with full saturation.
|
| 292 |
+
ordered = [c for c in rewards if c != HIGHLIGHT] + [c for c in rewards if c == HIGHLIGHT]
|
| 293 |
+
rho_per_reward: dict[str, float] = {}
|
| 294 |
+
for col in ordered:
|
| 295 |
+
vals = df[col].values
|
| 296 |
+
mask = ~(np.isnan(vals) | np.isnan(judge))
|
| 297 |
+
x_raw = vals[mask]
|
| 298 |
+
y_pts = y[mask]
|
| 299 |
+
if len(x_raw) < 3:
|
| 300 |
+
continue
|
| 301 |
+
denom = x_raw.max() - x_raw.min()
|
| 302 |
+
constant_x = denom == 0
|
| 303 |
+
if constant_x:
|
| 304 |
+
# All values identical (e.g. binary judge collapsed to 0). Place
|
| 305 |
+
# the points clustered at x=0 and draw a flat dotted line at
|
| 306 |
+
# the y-mean so the reward still appears in the panel.
|
| 307 |
+
x = np.zeros_like(x_raw, dtype=float)
|
| 308 |
+
else:
|
| 309 |
+
x = (x_raw - x_raw.min()) / denom
|
| 310 |
+
base = COLORS[col]
|
| 311 |
+
is_hi = col == HIGHLIGHT
|
| 312 |
+
if is_hi:
|
| 313 |
+
line_color = base
|
| 314 |
+
pt_color = (*lighten(base, 0.30), 0.90)
|
| 315 |
+
pt_edge = base
|
| 316 |
+
lw = STYLE["scatter_highlight_line_width"]
|
| 317 |
+
pt_size = STYLE["scatter_highlight_point_size"]
|
| 318 |
+
z_line = 5
|
| 319 |
+
z_pt = 4
|
| 320 |
+
else:
|
| 321 |
+
line_color = (*lighten(base, 0.40), 0.75)
|
| 322 |
+
pt_color = (*lighten(base, 0.60), 0.60)
|
| 323 |
+
pt_edge = "white"
|
| 324 |
+
lw = STYLE["scatter_other_line_width"]
|
| 325 |
+
pt_size = STYLE["scatter_other_point_size"]
|
| 326 |
+
z_line = 3
|
| 327 |
+
z_pt = 2
|
| 328 |
+
ax.scatter(x, y_pts, color=pt_color, s=pt_size * MARKER_SCALE[MARKERS[col]],
|
| 329 |
+
marker=MARKERS[col],
|
| 330 |
+
edgecolor=pt_edge, linewidth=0.4, zorder=z_pt)
|
| 331 |
+
xs = np.linspace(0, 1, 50)
|
| 332 |
+
if constant_x:
|
| 333 |
+
# No slope possible — flat dotted reference at the y mean.
|
| 334 |
+
y_mean = float(np.nanmean(y_pts))
|
| 335 |
+
ax.plot(xs, np.full_like(xs, y_mean), color=line_color,
|
| 336 |
+
lw=lw, linestyle=":", zorder=z_line)
|
| 337 |
+
else:
|
| 338 |
+
slope, intercept = np.polyfit(x, y_pts, 1)
|
| 339 |
+
ax.plot(xs, slope * xs + intercept, color=line_color, lw=lw, zorder=z_line)
|
| 340 |
+
rho_per_reward[col] = pearsonr(x_raw, judge[mask])[0]
|
| 341 |
+
|
| 342 |
+
ax.text(STYLE["bench_label_x"], STYLE["bench_label_y"],
|
| 343 |
+
BENCHMARK_DISPLAY[bench], transform=ax.transAxes,
|
| 344 |
+
ha="right", va="bottom",
|
| 345 |
+
fontsize=STYLE["bench_label_fontsize"], zorder=10,
|
| 346 |
+
bbox=dict(boxstyle="round,pad=0.32", facecolor="white",
|
| 347 |
+
edgecolor="0.7", linewidth=0.8, alpha=0.9))
|
| 348 |
+
ax.set_xlim(-0.03, 1.03)
|
| 349 |
+
ax.set_ylim(-0.03, 1.03)
|
| 350 |
+
ax.set_xticks([0.0, 0.5, 1.0])
|
| 351 |
+
ax.set_yticks([0.0, 0.5, 1.0])
|
| 352 |
+
ax.set_xlabel("Reward", fontsize=STYLE["panel_xlabel_fontsize"])
|
| 353 |
+
ax.set_ylabel("Score", fontsize=STYLE["panel_ylabel_fontsize"])
|
| 354 |
+
ax.tick_params(labelsize=STYLE["panel_tick_fontsize"])
|
| 355 |
+
ax.grid(True, color="0.75", linestyle="--", linewidth=0.7, alpha=0.85)
|
| 356 |
+
|
| 357 |
+
rho_by_bench[bench] = rho_per_reward
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
# ── r-vs-benchmark line plot in the middle of row 2 ───────────────────
|
| 361 |
+
xs_idx = np.arange(len(BENCHMARKS))
|
| 362 |
+
if split_y:
|
| 363 |
+
# Replace the single cell with two stacked sub-axes (broken y-axis).
|
| 364 |
+
gs = line_ax.get_subplotspec()
|
| 365 |
+
line_ax.remove()
|
| 366 |
+
inner = gs.subgridspec(2, 1,
|
| 367 |
+
height_ratios=split("height_ratio"),
|
| 368 |
+
hspace=split("hspace"))
|
| 369 |
+
top_ax = fig.add_subplot(inner[0])
|
| 370 |
+
bot_ax = fig.add_subplot(inner[1])
|
| 371 |
+
|
| 372 |
+
_draw_pearson_lines(top_ax, xs_idx, rewards, rho_by_bench)
|
| 373 |
+
_draw_pearson_lines(bot_ax, xs_idx, rewards, rho_by_bench)
|
| 374 |
+
|
| 375 |
+
top_ax.set_ylim(split("high_min"), split("high_max"))
|
| 376 |
+
bot_ax.set_ylim(split("low_min"), split("low_max"))
|
| 377 |
+
|
| 378 |
+
for ax_part in (top_ax, bot_ax):
|
| 379 |
+
ax_part.set_xticks(xs_idx)
|
| 380 |
+
ax_part.set_xticklabels([])
|
| 381 |
+
ax_part.tick_params(axis="y", labelsize=STYLE["line_tick_fontsize"])
|
| 382 |
+
ax_part.grid(True, color="0.75", linestyle="--", linewidth=0.7, alpha=0.85)
|
| 383 |
+
for side in ("top", "right", "left", "bottom"):
|
| 384 |
+
ax_part.spines[side].set_visible(True)
|
| 385 |
+
ax_part.spines[side].set_linewidth(0.8)
|
| 386 |
+
|
| 387 |
+
# Hide the spines facing the break.
|
| 388 |
+
top_ax.spines["bottom"].set_visible(False)
|
| 389 |
+
bot_ax.spines["top"].set_visible(False)
|
| 390 |
+
top_ax.tick_params(labelbottom=False, bottom=False)
|
| 391 |
+
|
| 392 |
+
# Diagonal break marks.
|
| 393 |
+
d = split("break_size")
|
| 394 |
+
kw = dict(color="black", clip_on=False, lw=1.0)
|
| 395 |
+
top_ax.plot((-d, +d), (-d, +d), transform=top_ax.transAxes, **kw)
|
| 396 |
+
top_ax.plot((1 - d, 1 + d), (-d, +d), transform=top_ax.transAxes, **kw)
|
| 397 |
+
bot_ax.plot((-d, +d), (1 - d, 1 + d), transform=bot_ax.transAxes, **kw)
|
| 398 |
+
bot_ax.plot((1 - d, 1 + d), (1 - d, 1 + d), transform=bot_ax.transAxes, **kw)
|
| 399 |
+
|
| 400 |
+
bot_ax.set_xlabel("Benchmark", fontsize=STYLE["line_xlabel_fontsize"])
|
| 401 |
+
# Centre the y-label vertically across BOTH sub-axes (and the gap).
|
| 402 |
+
# In bot_ax axes-fraction coords:
|
| 403 |
+
# bot_ax spans 0..1; gap above bot_ax = hspace * mean_h / h_bot;
|
| 404 |
+
# top_ax spans (1+gap) .. (1+gap+h_top/h_bot).
|
| 405 |
+
# Centre = average of bot_ax bottom (0) and top_ax top.
|
| 406 |
+
bot_ax.set_ylabel("r", fontsize=STYLE["line_ylabel_fontsize"])
|
| 407 |
+
h_top, h_bot = split("height_ratio")
|
| 408 |
+
gap_in_bot = split("hspace") * (h_top + h_bot) / (2 * h_bot)
|
| 409 |
+
y_centre = (1.0 + gap_in_bot + h_top / h_bot) / 2.0
|
| 410 |
+
bot_ax.yaxis.set_label_coords(split("ylabel_x"), y_centre)
|
| 411 |
+
else:
|
| 412 |
+
_draw_pearson_lines(line_ax, xs_idx, rewards, rho_by_bench)
|
| 413 |
+
line_ax.set_xticks(xs_idx)
|
| 414 |
+
line_ax.set_xticklabels([])
|
| 415 |
+
line_ax.set_xlabel("Benchmark", fontsize=STYLE["line_xlabel_fontsize"])
|
| 416 |
+
line_ax.set_ylabel("r", fontsize=STYLE["line_ylabel_fontsize"])
|
| 417 |
+
line_ax.tick_params(axis="y", labelsize=STYLE["line_tick_fontsize"])
|
| 418 |
+
line_ax.grid(True, color="0.75", linestyle="--", linewidth=0.7, alpha=0.85)
|
| 419 |
+
for side in ("top", "right", "left", "bottom"):
|
| 420 |
+
line_ax.spines[side].set_visible(True)
|
| 421 |
+
line_ax.spines[side].set_linewidth(0.8)
|
| 422 |
+
|
| 423 |
+
handles = []
|
| 424 |
+
for name in rewards:
|
| 425 |
+
is_hi = name == HIGHLIGHT
|
| 426 |
+
face = lighten(COLORS[name], 0.30 if is_hi else 0.60)
|
| 427 |
+
line_color = COLORS[name] if is_hi else (*lighten(COLORS[name], 0.40), 0.85)
|
| 428 |
+
edge = COLORS[name] if is_hi else "white"
|
| 429 |
+
handles.append(plt.Line2D(
|
| 430 |
+
[0], [0], color=line_color, marker=MARKERS[name],
|
| 431 |
+
markerfacecolor=face,
|
| 432 |
+
markeredgecolor=edge,
|
| 433 |
+
markersize=STYLE["legend_marker_size"] * (MARKER_SCALE[MARKERS[name]] ** 0.5),
|
| 434 |
+
lw=STYLE["legend_highlight_line_width"] if is_hi
|
| 435 |
+
else STYLE["legend_other_line_width"],
|
| 436 |
+
label=(legend_labels or {}).get(name, display_name(name))))
|
| 437 |
+
legend_x = (panels_w + STYLE["legend_x_offset"]) / (panels_w + right_pad)
|
| 438 |
+
fig.legend(handles=handles, loc="center left", ncol=1,
|
| 439 |
+
bbox_to_anchor=(legend_x, 0.5), fontsize=STYLE["legend_fontsize"],
|
| 440 |
+
frameon=False,
|
| 441 |
+
labelspacing=STYLE["legend_label_spacing"],
|
| 442 |
+
handlelength=STYLE["legend_handle_len"])
|
| 443 |
+
fig.tight_layout(rect=[0, 0, panels_w / (panels_w + right_pad), 1.0])
|
| 444 |
+
|
| 445 |
+
# Compute stair-step polygons after layout settles.
|
| 446 |
+
fig.canvas.draw()
|
| 447 |
+
renderer = fig.canvas.get_renderer()
|
| 448 |
+
pad_px = 4
|
| 449 |
+
for top_p, bot_p, poly, ax in _stair_polygons:
|
| 450 |
+
top_bb = top_p.get_window_extent(renderer)
|
| 451 |
+
bot_bb = bot_p.get_window_extent(renderer)
|
| 452 |
+
# Stair-step polygon (6 corners), clockwise from top-right.
|
| 453 |
+
join_y = (top_bb.y0 + bot_bb.y1) / 2
|
| 454 |
+
px = np.array([
|
| 455 |
+
[top_bb.x1 + pad_px, top_bb.y1 + pad_px], # top-right
|
| 456 |
+
[bot_bb.x1 + pad_px, bot_bb.y0 - pad_px], # bottom-right
|
| 457 |
+
[bot_bb.x0 - pad_px, bot_bb.y0 - pad_px], # bottom-left
|
| 458 |
+
[bot_bb.x0 - pad_px, join_y], # step up
|
| 459 |
+
[top_bb.x0 - pad_px, join_y], # step right (under top row)
|
| 460 |
+
[top_bb.x0 - pad_px, top_bb.y1 + pad_px], # up to top-left of top row
|
| 461 |
+
])
|
| 462 |
+
data_pts = ax.transData.inverted().transform(px)
|
| 463 |
+
poly.set_xy(data_pts)
|
| 464 |
+
|
| 465 |
+
fig.savefig(out_stem.with_suffix(".png"), dpi=200)
|
| 466 |
+
fig.savefig(out_stem.with_suffix(".pdf"))
|
| 467 |
+
plt.close(fig)
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
def main() -> None:
|
| 471 |
+
sections = parse_sections(SRC)
|
| 472 |
+
missing = [b for b in BENCHMARKS if b not in sections]
|
| 473 |
+
if missing:
|
| 474 |
+
raise SystemExit(f"benchmarks not in source file: {missing}")
|
| 475 |
+
|
| 476 |
+
plot_group(sections, GROUPS["rewards_classic"], ROOT / "alignment_reward",
|
| 477 |
+
split_key="reward")
|
| 478 |
+
plot_group(sections, GROUPS["rewards_vqa"], ROOT / "alignment_vqa",
|
| 479 |
+
legend_labels={
|
| 480 |
+
"VQAScore-binary-9B": "Qwen3.5\n(Binary)",
|
| 481 |
+
"VQAScore-Gemma-4-E4B": "Gemma",
|
| 482 |
+
"VQAScore-9B": "Qwen3.5",
|
| 483 |
+
},
|
| 484 |
+
split_key="vqa")
|
| 485 |
+
print("wrote alignment_reward.{png,pdf} and alignment_vqa.{png,pdf}")
|
| 486 |
+
|
| 487 |
+
|
| 488 |
+
if __name__ == "__main__":
|
| 489 |
+
main()
|
figures/alignment/plot_reward_alignment.py
ADDED
|
@@ -0,0 +1,402 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""How well do the four classic rewards (HPSv3, PickScore, ImageReward,
|
| 2 |
+
UnifiedReward) align with each other?
|
| 3 |
+
|
| 4 |
+
We pool all (model, benchmark) cells from sheet_exports/alignment.txt, z-score
|
| 5 |
+
each (reward, benchmark) so cross-benchmark scales are comparable, then show:
|
| 6 |
+
|
| 7 |
+
1. ``reward_alignment_pairgrid.{png,pdf}`` — 4×4 pair grid:
|
| 8 |
+
diagonal = KDE of each reward's pooled distribution
|
| 9 |
+
lower-tri = pairwise scatter, colour-coded by benchmark
|
| 10 |
+
upper-tri = Pearson r (large) + Spearman ρ (small)
|
| 11 |
+
|
| 12 |
+
2. ``reward_alignment_density.{png,pdf}`` — single panel overlay of the four
|
| 13 |
+
z-scored marginal KDEs.
|
| 14 |
+
"""
|
| 15 |
+
from __future__ import annotations
|
| 16 |
+
|
| 17 |
+
import re
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
|
| 20 |
+
import matplotlib.colors as mcolors
|
| 21 |
+
import matplotlib.font_manager as fm
|
| 22 |
+
import matplotlib.pyplot as plt
|
| 23 |
+
import numpy as np
|
| 24 |
+
import pandas as pd
|
| 25 |
+
from scipy.stats import gaussian_kde, pearsonr, spearmanr
|
| 26 |
+
from sklearn.decomposition import PCA
|
| 27 |
+
|
| 28 |
+
ROOT = Path(__file__).resolve().parent
|
| 29 |
+
SRC = ROOT.parent.parent / "sheet_exports" / "alignment.txt"
|
| 30 |
+
|
| 31 |
+
# Shared STIX Two Text typeface.
|
| 32 |
+
_FONT = ROOT.parent / "_fonts" / "STIX-Two-Text-Regular.ttf"
|
| 33 |
+
fm.fontManager.addfont(str(_FONT))
|
| 34 |
+
_FAMILY = fm.FontProperties(fname=str(_FONT)).get_name()
|
| 35 |
+
plt.rcParams.update({
|
| 36 |
+
"font.family": _FAMILY,
|
| 37 |
+
"font.serif": [_FAMILY, "DejaVu Serif"],
|
| 38 |
+
"mathtext.fontset": "stix",
|
| 39 |
+
"axes.unicode_minus": False,
|
| 40 |
+
})
|
| 41 |
+
|
| 42 |
+
REWARDS = ["HPSv3", "PickScore", "ImageReward", "UnifiedReward-9B"]
|
| 43 |
+
DISPLAY = {
|
| 44 |
+
"HPSv3": "HPSv3",
|
| 45 |
+
"PickScore": "PickScore",
|
| 46 |
+
"ImageReward": "ImageReward",
|
| 47 |
+
"UnifiedReward-9B": "UnifiedReward",
|
| 48 |
+
}
|
| 49 |
+
# Skip: t2icorebench composite (kept via its split components),
|
| 50 |
+
# plus sciencet2i / wise per current scope.
|
| 51 |
+
SKIP_BENCHES = {"t2icorebench", "t2icorebench_reasoning", "sciencet2i", "wise"}
|
| 52 |
+
|
| 53 |
+
# Two-tone palette: 边缘 (字体 / 条形 / region 边线) 用饱和色,region 内部用浅色。
|
| 54 |
+
# 按色相对应: 蓝 = ImageReward, 橙 = HPSv3, 红 = UnifiedReward-9B, 绿 = PickScore.
|
| 55 |
+
EDGE_COLORS = {
|
| 56 |
+
"HPSv3": "#e59837", # 橙
|
| 57 |
+
"PickScore": "#5cb360", # 绿 (与 fill 相同)
|
| 58 |
+
"ImageReward": "#3a8dde", # 蓝
|
| 59 |
+
"UnifiedReward-9B": "#d94f4f", # 红
|
| 60 |
+
}
|
| 61 |
+
FILL_COLORS = {
|
| 62 |
+
"HPSv3": "#ffdaae", # 浅橙
|
| 63 |
+
"PickScore": "#bcebbd", # 浅绿
|
| 64 |
+
"ImageReward": "#b1d9ff", # 浅蓝
|
| 65 |
+
"UnifiedReward-9B": "#ffb5b5", # 浅红
|
| 66 |
+
}
|
| 67 |
+
# COLORS 保留, 给 bar / label 用饱和色。
|
| 68 |
+
COLORS = EDGE_COLORS
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def parse_sections(path: Path) -> dict[str, pd.DataFrame]:
|
| 72 |
+
text = path.read_text()
|
| 73 |
+
out: dict[str, pd.DataFrame] = {}
|
| 74 |
+
for m in re.finditer(r"=== (\S+) ===\n(.*?)(?=\n=== |\Z)", text, re.DOTALL):
|
| 75 |
+
name = m.group(1)
|
| 76 |
+
if name in SKIP_BENCHES:
|
| 77 |
+
continue
|
| 78 |
+
body = m.group(2).strip().splitlines()
|
| 79 |
+
header = body[0].split("\t")
|
| 80 |
+
rows = [ln.split("\t") for ln in body[1:] if ln.strip()]
|
| 81 |
+
df = pd.DataFrame(rows, columns=header).set_index("Model")
|
| 82 |
+
df = df.apply(pd.to_numeric, errors="coerce")
|
| 83 |
+
out[name] = df
|
| 84 |
+
return out
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def build_long_df(sections: dict[str, pd.DataFrame]) -> pd.DataFrame:
|
| 88 |
+
"""One row per (benchmark, model) with z-scored reward columns."""
|
| 89 |
+
frames = []
|
| 90 |
+
for bench, df in sections.items():
|
| 91 |
+
sub = df[REWARDS].copy()
|
| 92 |
+
sub = (sub - sub.mean()) / sub.std(ddof=0)
|
| 93 |
+
sub["benchmark"] = bench
|
| 94 |
+
sub["model"] = df.index
|
| 95 |
+
frames.append(sub.reset_index(drop=True))
|
| 96 |
+
return pd.concat(frames, ignore_index=True)
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
def lighten(color, amount: float = 0.5):
|
| 100 |
+
r, g, b = mcolors.to_rgb(color)
|
| 101 |
+
return (r + (1 - r) * amount, g + (1 - g) * amount, b + (1 - b) * amount)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def darken(color, amount: float = 0.35):
|
| 105 |
+
r, g, b = mcolors.to_rgb(color)
|
| 106 |
+
return (r * (1 - amount), g * (1 - amount), b * (1 - amount))
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
# Labels / bar fills / region 边框: 纯正 Google 配色, 不做 darken / lighten。
|
| 110 |
+
LABEL_COLORS = dict(COLORS)
|
| 111 |
+
|
| 112 |
+
# ─── BAR CHART KNOBS — edit these to tweak the upper-right bar chart ──
|
| 113 |
+
# The bar right-edge is anchored at a FIXED data position (right_anchor=1.0),
|
| 114 |
+
# so changing bar_length_scale only stretches bars LEFTWARD — the right edge
|
| 115 |
+
# stays locked to bar_ax's right spine regardless of scale.
|
| 116 |
+
BAR_CHART = dict(
|
| 117 |
+
block_rows=(0,), # which 4×4 grid rows the chart spans
|
| 118 |
+
block_cols=(1, 2, 3), # which 4×4 grid cols the chart spans
|
| 119 |
+
pad_x_left=0.04, # left padding inside the block (room for value text overflow)
|
| 120 |
+
pad_x_right=0.15, # right padding (reserved for name text; names right-aligned to matrix right)
|
| 121 |
+
pad_top=0.1, # top padding inside the block
|
| 122 |
+
pad_bottom=0.06, # bottom padding inside the block
|
| 123 |
+
bar_height=0.05, # bar thickness as fraction of FIGURE height; bigger → bar_ax grows taller
|
| 124 |
+
bar_gap=0.04, # gap between bars as fraction of FIGURE height; bigger → bar_ax grows taller
|
| 125 |
+
baseline_gap=0.02, # smaller = bigger length-difference ratio
|
| 126 |
+
bar_length_scale=5.0, # bigger = longer bars (xlim_lo auto-extends to fit)
|
| 127 |
+
xlim_pad_left=0.12, # extra data-space left of longest bar (for value text)
|
| 128 |
+
value_fontsize=16, # numeric label fontsize
|
| 129 |
+
name_fontsize=16, # reward name fontsize
|
| 130 |
+
text_offset=0.012, # x gap between bar end and adjacent text
|
| 131 |
+
)
|
| 132 |
+
# bar_ax height (in figure coords) = 4*bar_height + 3*bar_gap. Top is anchored
|
| 133 |
+
# at the top of block_rows; bottom bar moves DOWN as bar_height/bar_gap grow,
|
| 134 |
+
# possibly overlapping cells in row 1 / etc. (which is fine — they're empty).
|
| 135 |
+
# ─────────────────────────────────────────────────────────────────────
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
# ---------- figure 1: pair grid ----------
|
| 139 |
+
|
| 140 |
+
def _kde_region(ax, coords: np.ndarray, weights: np.ndarray,
|
| 141 |
+
edge_color: str, fill_color: str,
|
| 142 |
+
xlim: tuple[float, float], ylim: tuple[float, float],
|
| 143 |
+
mass_level: float = 0.5, bw: float = 0.45,
|
| 144 |
+
grid_n: int = 180,
|
| 145 |
+
fill_alpha: float = 0.55) -> None:
|
| 146 |
+
"""Filled 2D-KDE contour: lighter fill_color inside, saturated edge_color outline."""
|
| 147 |
+
xs = np.linspace(xlim[0], xlim[1], grid_n)
|
| 148 |
+
ys = np.linspace(ylim[0], ylim[1], grid_n)
|
| 149 |
+
X, Y = np.meshgrid(xs, ys)
|
| 150 |
+
grid = np.vstack([X.ravel(), Y.ravel()])
|
| 151 |
+
|
| 152 |
+
w = np.clip(weights, 0, None)
|
| 153 |
+
if w.sum() == 0:
|
| 154 |
+
return
|
| 155 |
+
kde = gaussian_kde(coords.T, weights=w, bw_method=bw)
|
| 156 |
+
Z = kde(grid).reshape(X.shape)
|
| 157 |
+
|
| 158 |
+
flat = np.sort(Z.ravel())[::-1]
|
| 159 |
+
cum = np.cumsum(flat)
|
| 160 |
+
cum /= cum[-1]
|
| 161 |
+
idx = np.searchsorted(cum, mass_level)
|
| 162 |
+
level = flat[min(idx, len(flat) - 1)]
|
| 163 |
+
|
| 164 |
+
ax.contourf(X, Y, Z, levels=[level, Z.max() + 1e-9],
|
| 165 |
+
colors=[fill_color], alpha=fill_alpha, zorder=2)
|
| 166 |
+
ax.contour(X, Y, Z, levels=[level], colors=[edge_color],
|
| 167 |
+
linewidths=2.0, zorder=3)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def plot_pairgrid(long_df: pd.DataFrame, out_stem: Path) -> None:
|
| 171 |
+
"""Pair grid where:
|
| 172 |
+
diagonal = each reward's PCA-based KDE region
|
| 173 |
+
lower triangle = the two rewards' regions overlaid + Pearson r
|
| 174 |
+
upper triangle = blank (axes hidden)
|
| 175 |
+
"""
|
| 176 |
+
n = len(REWARDS)
|
| 177 |
+
|
| 178 |
+
# Cells to embed: drop any row missing a reward column.
|
| 179 |
+
df = long_df.dropna(subset=REWARDS).reset_index(drop=True)
|
| 180 |
+
M = df[REWARDS].to_numpy()
|
| 181 |
+
pca = PCA(n_components=2)
|
| 182 |
+
coords = pca.fit_transform(M)
|
| 183 |
+
|
| 184 |
+
# Crop tightly around where the regions actually live: bounding box of
|
| 185 |
+
# cells whose weight (reward z-score) is positive for *any* reward,
|
| 186 |
+
# using a generous percentile to ignore far outliers.
|
| 187 |
+
# Compute the union bbox of every reward's actual region (where the KDE
|
| 188 |
+
# exceeds the 50%-mass level), so the panels are framed by what's drawn
|
| 189 |
+
# rather than by where cells happen to land.
|
| 190 |
+
full_xlim = (coords[:, 0].min() - 1.0, coords[:, 0].max() + 1.0)
|
| 191 |
+
full_ylim = (coords[:, 1].min() - 1.0, coords[:, 1].max() + 1.0)
|
| 192 |
+
region_xs, region_ys = [], []
|
| 193 |
+
grid_n = 220
|
| 194 |
+
xs_g = np.linspace(full_xlim[0], full_xlim[1], grid_n)
|
| 195 |
+
ys_g = np.linspace(full_ylim[0], full_ylim[1], grid_n)
|
| 196 |
+
Xg, Yg = np.meshgrid(xs_g, ys_g)
|
| 197 |
+
grid_pts = np.vstack([Xg.ravel(), Yg.ravel()])
|
| 198 |
+
for r in REWARDS:
|
| 199 |
+
w = np.clip(df[r].to_numpy(), 0, None)
|
| 200 |
+
if w.sum() == 0:
|
| 201 |
+
continue
|
| 202 |
+
kde = gaussian_kde(coords.T, weights=w, bw_method=0.45)
|
| 203 |
+
Z = kde(grid_pts).reshape(Xg.shape)
|
| 204 |
+
flat = np.sort(Z.ravel())[::-1]
|
| 205 |
+
cum = np.cumsum(flat) / flat.sum()
|
| 206 |
+
level = flat[min(np.searchsorted(cum, 0.5), len(flat) - 1)]
|
| 207 |
+
mask = Z >= level
|
| 208 |
+
if mask.any():
|
| 209 |
+
region_xs.extend(Xg[mask].tolist())
|
| 210 |
+
region_ys.extend(Yg[mask].tolist())
|
| 211 |
+
rxs = np.array(region_xs)
|
| 212 |
+
rys = np.array(region_ys)
|
| 213 |
+
qx_lo, qx_hi = rxs.min(), rxs.max()
|
| 214 |
+
qy_lo, qy_hi = rys.min(), rys.max()
|
| 215 |
+
xrange = qx_hi - qx_lo
|
| 216 |
+
yrange = qy_hi - qy_lo
|
| 217 |
+
xlim = (qx_lo - 0.14 * xrange, qx_hi + 0.14 * xrange)
|
| 218 |
+
ylim = (qy_lo - 0.20 * yrange, qy_hi + 0.20 * yrange)
|
| 219 |
+
|
| 220 |
+
fig, axes = plt.subplots(n, n, figsize=(13.5, 6.0),
|
| 221 |
+
gridspec_kw=dict(wspace=0.0, hspace=0.0))
|
| 222 |
+
|
| 223 |
+
for i, ri in enumerate(REWARDS):
|
| 224 |
+
for j, rj in enumerate(REWARDS):
|
| 225 |
+
ax = axes[i, j]
|
| 226 |
+
if i < j:
|
| 227 |
+
ax.axis("off")
|
| 228 |
+
continue
|
| 229 |
+
|
| 230 |
+
if i == j:
|
| 231 |
+
_kde_region(ax, coords, df[ri].to_numpy(),
|
| 232 |
+
EDGE_COLORS[ri], FILL_COLORS[ri], xlim, ylim)
|
| 233 |
+
ax.text(0.04, 0.95, DISPLAY[ri], transform=ax.transAxes,
|
| 234 |
+
fontsize=17, color=LABEL_COLORS[ri], fontweight="bold",
|
| 235 |
+
ha="left", va="top")
|
| 236 |
+
else:
|
| 237 |
+
_kde_region(ax, coords, df[rj].to_numpy(),
|
| 238 |
+
EDGE_COLORS[rj], FILL_COLORS[rj], xlim, ylim)
|
| 239 |
+
_kde_region(ax, coords, df[ri].to_numpy(),
|
| 240 |
+
EDGE_COLORS[ri], FILL_COLORS[ri], xlim, ylim)
|
| 241 |
+
xs = df[rj].to_numpy()
|
| 242 |
+
ys = df[ri].to_numpy()
|
| 243 |
+
r_val = pearsonr(xs, ys)[0]
|
| 244 |
+
ax.text(0.04, 0.95, f"r = {r_val:.2f}",
|
| 245 |
+
transform=ax.transAxes, ha="left", va="top",
|
| 246 |
+
fontsize=17, fontweight="bold", color="0.15")
|
| 247 |
+
|
| 248 |
+
ax.set_xlim(xlim)
|
| 249 |
+
ax.set_ylim(ylim)
|
| 250 |
+
ax.xaxis.set_major_locator(
|
| 251 |
+
plt.FixedLocator(np.linspace(xlim[0], xlim[1], 5)))
|
| 252 |
+
ax.yaxis.set_major_locator(
|
| 253 |
+
plt.FixedLocator(np.linspace(ylim[0], ylim[1], 5)))
|
| 254 |
+
ax.tick_params(labelbottom=False, labelleft=False, length=0)
|
| 255 |
+
ax.grid(True, color="0.82", linewidth=0.5, alpha=0.8, zorder=1)
|
| 256 |
+
for spine in ax.spines.values():
|
| 257 |
+
spine.set_linewidth(0.8)
|
| 258 |
+
|
| 259 |
+
fig.tight_layout(pad=0.2)
|
| 260 |
+
|
| 261 |
+
# Figure-level PC1 / PC2 labels, centered on the whole 4×4 matrix.
|
| 262 |
+
matrix_left = axes[0, 0].get_position().x0
|
| 263 |
+
matrix_right = axes[n - 1, n - 1].get_position().x1
|
| 264 |
+
matrix_bottom = axes[n - 1, 0].get_position().y0
|
| 265 |
+
matrix_top = axes[0, 0].get_position().y1
|
| 266 |
+
fig.text((matrix_left + matrix_right) / 2, matrix_bottom - 0.020,
|
| 267 |
+
"PC1", ha="center", va="top", fontsize=20)
|
| 268 |
+
fig.text(matrix_left - 0.010, (matrix_bottom + matrix_top) / 2,
|
| 269 |
+
"PC2", ha="right", va="center", fontsize=20, rotation=90)
|
| 270 |
+
|
| 271 |
+
# Bar chart in the upper-right area — controlled by the BAR_CHART dict.
|
| 272 |
+
cfg = BAR_CHART
|
| 273 |
+
block_cells = [axes[i, j].get_position()
|
| 274 |
+
for i in cfg["block_rows"] for j in cfg["block_cols"]]
|
| 275 |
+
bx0 = min(p.x0 for p in block_cells)
|
| 276 |
+
bx1 = max(p.x1 for p in block_cells)
|
| 277 |
+
by0 = min(p.y0 for p in block_cells)
|
| 278 |
+
by1 = max(p.y1 for p in block_cells)
|
| 279 |
+
block_w = bx1 - bx0
|
| 280 |
+
block_h = by1 - by0
|
| 281 |
+
mx_left = block_w * cfg["pad_x_left"]
|
| 282 |
+
mx_right = block_w * cfg["pad_x_right"]
|
| 283 |
+
my_top = block_h * cfg["pad_top"]
|
| 284 |
+
# bar_ax PHYSICAL height (figure coords) is driven by bar_height + bar_gap
|
| 285 |
+
# so that growing those values pushes the bottom bar downward.
|
| 286 |
+
n_bars = len(REWARDS)
|
| 287 |
+
bar_ax_h = n_bars * cfg["bar_height"] + (n_bars - 1) * cfg["bar_gap"]
|
| 288 |
+
bar_ax_top = by1 - my_top # always anchored to top of block
|
| 289 |
+
bar_ax = fig.add_axes([bx0 + mx_left, bar_ax_top - bar_ax_h,
|
| 290 |
+
block_w - mx_left - mx_right,
|
| 291 |
+
bar_ax_h])
|
| 292 |
+
# Render the bar chart BEHIND every matrix panel so any region/diagonal
|
| 293 |
+
# cell the bar passes through cleanly covers the bar.
|
| 294 |
+
bar_ax.set_zorder(-1)
|
| 295 |
+
for ax_row in axes:
|
| 296 |
+
for ax in ax_row:
|
| 297 |
+
ax.set_zorder(1)
|
| 298 |
+
# Matrix panels need transparent backgrounds where they're "off"
|
| 299 |
+
# (upper-tri); for visible cells keep their white fill so they
|
| 300 |
+
# fully occlude the bar chart underneath.
|
| 301 |
+
|
| 302 |
+
pairs = []
|
| 303 |
+
for r in REWARDS:
|
| 304 |
+
others = [pearsonr(df[r].to_numpy(), df[r2].to_numpy())[0]
|
| 305 |
+
for r2 in REWARDS if r2 != r]
|
| 306 |
+
pairs.append((r, float(np.mean(others))))
|
| 307 |
+
pairs.sort(key=lambda x: -x[1]) # longest bar at top
|
| 308 |
+
sorted_rewards = [r for r, _ in pairs]
|
| 309 |
+
sorted_means = [m for _, m in pairs]
|
| 310 |
+
|
| 311 |
+
# In axis-y (ylim=0..1), bars fill the chart exactly: bar+gap fractions =
|
| 312 |
+
# bar_height/total and bar_gap/total of axis height.
|
| 313 |
+
bh = cfg["bar_height"] / bar_ax_h
|
| 314 |
+
bg = cfg["bar_gap"] / bar_ax_h
|
| 315 |
+
spacing = bh + bg
|
| 316 |
+
top_y = 1.0 - bh / 2
|
| 317 |
+
y_pos = np.array([top_y - i * spacing for i in range(n_bars)])
|
| 318 |
+
baseline = min(sorted_means) - cfg["baseline_gap"]
|
| 319 |
+
widths = [(m - baseline) * cfg["bar_length_scale"] for m in sorted_means]
|
| 320 |
+
# Right anchor is FIXED — bars always end at xlim_hi (= bar_ax right spine).
|
| 321 |
+
right_anchor = 1.0
|
| 322 |
+
left_anchors = [right_anchor - w for w in widths]
|
| 323 |
+
bar_colors = [FILL_COLORS[r] for r in sorted_rewards]
|
| 324 |
+
|
| 325 |
+
bar_ax.barh(y_pos, widths, left=left_anchors, color=bar_colors,
|
| 326 |
+
edgecolor="white", linewidth=1.0, alpha=1.0,
|
| 327 |
+
height=bh, zorder=3)
|
| 328 |
+
bar_ax.set_xlim(min(left_anchors) - cfg["xlim_pad_left"], right_anchor)
|
| 329 |
+
bar_ax.set_ylim(0, 1)
|
| 330 |
+
|
| 331 |
+
# Drawn via fig.text so labels sit ABOVE every matrix panel (axes zorder
|
| 332 |
+
# doesn't affect figure-level artists). Values right-aligned at each bar's
|
| 333 |
+
# left end; names left-aligned at common x past bar right.
|
| 334 |
+
def _to_fig(xd, yd):
|
| 335 |
+
disp = bar_ax.transData.transform((xd, yd))
|
| 336 |
+
return fig.transFigure.inverted().transform(disp)
|
| 337 |
+
|
| 338 |
+
for y, r, m, lo in zip(y_pos, sorted_rewards, sorted_means, left_anchors,
|
| 339 |
+
strict=False):
|
| 340 |
+
fx, fy = _to_fig(lo - cfg["text_offset"], y)
|
| 341 |
+
fig.text(fx, fy, f"{m:.2f}", ha="right", va="center",
|
| 342 |
+
fontsize=cfg["value_fontsize"], color="0.15",
|
| 343 |
+
fontweight="bold")
|
| 344 |
+
nfx, nfy = _to_fig(right_anchor + cfg["text_offset"], y)
|
| 345 |
+
fig.text(nfx, nfy, DISPLAY[r], ha="left", va="center",
|
| 346 |
+
fontsize=cfg["name_fontsize"], color=LABEL_COLORS[r],
|
| 347 |
+
fontweight="bold")
|
| 348 |
+
bar_ax.set_xticks([])
|
| 349 |
+
bar_ax.set_yticks([])
|
| 350 |
+
for spine in bar_ax.spines.values():
|
| 351 |
+
spine.set_visible(False)
|
| 352 |
+
fig.savefig(out_stem.with_suffix(".pdf"), bbox_inches="tight")
|
| 353 |
+
plt.close(fig)
|
| 354 |
+
print(f"wrote {out_stem.name}.pdf")
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
# ---------- figure 2: marginal density overlay ----------
|
| 358 |
+
|
| 359 |
+
def plot_density_overlay(long_df: pd.DataFrame, out_stem: Path) -> None:
|
| 360 |
+
fig, ax = plt.subplots(figsize=(8, 4.4))
|
| 361 |
+
|
| 362 |
+
pooled = long_df[REWARDS].to_numpy().ravel()
|
| 363 |
+
pooled = pooled[~np.isnan(pooled)]
|
| 364 |
+
lo, hi = np.quantile(pooled, [0.005, 0.995])
|
| 365 |
+
pad = (hi - lo) * 0.05
|
| 366 |
+
lo, hi = lo - pad, hi + pad
|
| 367 |
+
grid = np.linspace(lo, hi, 300)
|
| 368 |
+
|
| 369 |
+
for r in REWARDS:
|
| 370 |
+
vals = long_df[r].dropna().to_numpy()
|
| 371 |
+
kde = gaussian_kde(vals, bw_method=0.4)
|
| 372 |
+
ys = kde(grid)
|
| 373 |
+
ax.fill_between(grid, ys, color=COLORS[r], alpha=0.18, zorder=2)
|
| 374 |
+
ax.plot(grid, ys, color=COLORS[r], lw=2.5, zorder=3, label=DISPLAY[r])
|
| 375 |
+
|
| 376 |
+
ax.set_xlim(lo, hi)
|
| 377 |
+
ax.set_xlabel("Score (z-scored within each benchmark)", fontsize=13)
|
| 378 |
+
ax.set_ylabel("Density", fontsize=13)
|
| 379 |
+
ax.set_yticks([])
|
| 380 |
+
ax.tick_params(axis="x", labelsize=11)
|
| 381 |
+
ax.grid(True, axis="x", linestyle=":", linewidth=0.5, alpha=0.5)
|
| 382 |
+
for spine in ("top", "right"):
|
| 383 |
+
ax.spines[spine].set_visible(False)
|
| 384 |
+
ax.legend(fontsize=12, frameon=False, loc="upper right", handlelength=2.2)
|
| 385 |
+
fig.tight_layout()
|
| 386 |
+
fig.savefig(out_stem.with_suffix(".png"), dpi=200, bbox_inches="tight")
|
| 387 |
+
fig.savefig(out_stem.with_suffix(".pdf"), bbox_inches="tight")
|
| 388 |
+
plt.close(fig)
|
| 389 |
+
print(f"wrote {out_stem.name}.png / .pdf")
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
def main() -> None:
|
| 393 |
+
sections = parse_sections(SRC)
|
| 394 |
+
print("benchmarks pooled:", sorted(sections.keys()))
|
| 395 |
+
long_df = build_long_df(sections)
|
| 396 |
+
print(f"pooled rows: {len(long_df)} (= {len(sections)} benchmarks × ~{long_df['model'].nunique()} models)")
|
| 397 |
+
|
| 398 |
+
plot_pairgrid(long_df, ROOT / "reward_alignment_pairgrid")
|
| 399 |
+
|
| 400 |
+
|
| 401 |
+
if __name__ == "__main__":
|
| 402 |
+
main()
|
figures/alignment/reward_alignment_pairgrid.pdf
ADDED
|
Binary file (66.3 kB). View file
|
|
|
figures/benchmark/benchmark_overview.pdf
ADDED
|
Binary file (25.1 kB). View file
|
|
|
figures/benchmark/benchmark_overview.png
ADDED
|
Git LFS Details
|
figures/benchmark/plot_benchmark_overview.py
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Benchmark overview scatter.
|
| 2 |
+
|
| 3 |
+
X-axis: average prompt length (words) per benchmark.
|
| 4 |
+
Y-axis: average MLLM-Judge performance across all evaluated models, normalised
|
| 5 |
+
to the benchmark's native max score so values land in [0, 1].
|
| 6 |
+
Marker: filled circle whose area is proportional to the benchmark's prompt count.
|
| 7 |
+
|
| 8 |
+
Data source:
|
| 9 |
+
- sheet_exports/alignment.txt -> per-benchmark MLLM_Judge scores per model
|
| 10 |
+
- HuggingFace datasets -> prompt counts and average prompt length
|
| 11 |
+
"""
|
| 12 |
+
from __future__ import annotations
|
| 13 |
+
|
| 14 |
+
import re
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
from statistics import mean
|
| 17 |
+
|
| 18 |
+
import matplotlib.font_manager as fm
|
| 19 |
+
import matplotlib.pyplot as plt
|
| 20 |
+
import numpy as np
|
| 21 |
+
from datasets import load_dataset
|
| 22 |
+
|
| 23 |
+
ROOT = Path(__file__).resolve().parent
|
| 24 |
+
SRC = ROOT.parent.parent / "sheet_exports" / "alignment.txt"
|
| 25 |
+
|
| 26 |
+
_FONT = ROOT.parent / "_fonts" / "STIX-Two-Text-Regular.ttf"
|
| 27 |
+
fm.fontManager.addfont(str(_FONT))
|
| 28 |
+
_FAMILY = fm.FontProperties(fname=str(_FONT)).get_name()
|
| 29 |
+
plt.rcParams.update({
|
| 30 |
+
"font.family": _FAMILY,
|
| 31 |
+
"font.serif": [_FAMILY, "DejaVu Serif"],
|
| 32 |
+
"mathtext.fontset": "stix",
|
| 33 |
+
"axes.unicode_minus": False,
|
| 34 |
+
})
|
| 35 |
+
|
| 36 |
+
JUDGE_COL = "MLLM_Judge"
|
| 37 |
+
|
| 38 |
+
# Display name, native score max (used to normalise the judge column to [0, 1]).
|
| 39 |
+
BENCHMARKS = {
|
| 40 |
+
"longbencht2i": {"display": "LongBench-T2I", "score_max": 5.0},
|
| 41 |
+
"spatialgeneval": {"display": "SpatialGenEval", "score_max": 100.0},
|
| 42 |
+
"t2icompbench": {"display": "T2I-CompBench", "score_max": 5.0},
|
| 43 |
+
"t2icorebench_composition": {"display": "T2I-CoReBench", "score_max": 1.0},
|
| 44 |
+
"tiifbench": {"display": "TIIF-Bench", "score_max": 1.0},
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
# ---------------------------------------------------------------------------
|
| 48 |
+
# Per-benchmark label tweaks. Edit only this block to change how each label
|
| 49 |
+
# is rendered.
|
| 50 |
+
# fontsize : text size in points
|
| 51 |
+
# dx, dy : offset in points from the bubble center
|
| 52 |
+
# (positive dy = above, negative = below; positive dx = right)
|
| 53 |
+
# ha, va : matplotlib horizontal/vertical alignment ("left"/"center"/"right",
|
| 54 |
+
# "top"/"center"/"bottom"). va="auto" places the label just outside
|
| 55 |
+
# the bubble's top edge automatically.
|
| 56 |
+
# ---------------------------------------------------------------------------
|
| 57 |
+
LABEL_STYLE: dict[str, dict] = {
|
| 58 |
+
"longbencht2i": {"fontsize": 11, "dx": 40, "dy": -5, "ha": "center", "va": "auto"},
|
| 59 |
+
"spatialgeneval": {"fontsize": 11, "dx": -5, "dy": -60, "ha": "center", "va": "auto"},
|
| 60 |
+
"t2icompbench": {"fontsize": 11, "dx": 0, "dy": -5, "ha": "center", "va": "auto"},
|
| 61 |
+
"t2icorebench_composition": {"fontsize": 11, "dx": 10, "dy": -5, "ha": "center", "va": "auto"},
|
| 62 |
+
"tiifbench": {"fontsize": 11, "dx": 0, "dy": -8, "ha": "center", "va": "auto"},
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
# (HF dataset path, callable returning the list of generated prompt strings)
|
| 66 |
+
HF_SOURCES = {
|
| 67 |
+
"longbencht2i": ("Jialuo21/LongBench-T2I", lambda d: list(d["prompt"])),
|
| 68 |
+
"spatialgeneval": ("Jialuo21/SpatialGenEval", lambda d: list(d["prompt"])),
|
| 69 |
+
"t2icompbench": ("Jialuo21/T2I_CompBench", lambda d: list(d["prompt"])),
|
| 70 |
+
"t2icorebench_composition": (
|
| 71 |
+
"Jialuo21/T2I-CoReBench",
|
| 72 |
+
lambda d: [p for p, t in zip(d["Prompt"], d["task"], strict=False) if str(t).startswith("C-")],
|
| 73 |
+
),
|
| 74 |
+
# TIIF-Bench's default plan emits both the short and long description per row.
|
| 75 |
+
"tiifbench": ("Jialuo21/TIIF-Bench",
|
| 76 |
+
lambda d: list(d["short_description"]) + list(d["long_description"])),
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def parse_alignment(path: Path) -> dict[str, dict[str, float]]:
|
| 81 |
+
"""Return {benchmark_name: {model: judge_score}}."""
|
| 82 |
+
text = path.read_text()
|
| 83 |
+
blocks = re.split(r"=== (\w+) ===\n", text)
|
| 84 |
+
out: dict[str, dict[str, float]] = {}
|
| 85 |
+
for i in range(1, len(blocks), 2):
|
| 86 |
+
name = blocks[i].strip()
|
| 87 |
+
body = blocks[i + 1].strip().splitlines()
|
| 88 |
+
if not body:
|
| 89 |
+
continue
|
| 90 |
+
header = body[0].split("\t")
|
| 91 |
+
try:
|
| 92 |
+
judge_idx = header.index(JUDGE_COL)
|
| 93 |
+
except ValueError:
|
| 94 |
+
continue
|
| 95 |
+
scores: dict[str, float] = {}
|
| 96 |
+
for row in body[1:]:
|
| 97 |
+
cells = row.split("\t")
|
| 98 |
+
if len(cells) <= judge_idx:
|
| 99 |
+
continue
|
| 100 |
+
cell = cells[judge_idx].strip()
|
| 101 |
+
if not cell or cell == "-":
|
| 102 |
+
continue
|
| 103 |
+
try:
|
| 104 |
+
scores[cells[0]] = float(cell)
|
| 105 |
+
except ValueError:
|
| 106 |
+
continue
|
| 107 |
+
if scores:
|
| 108 |
+
out[name] = scores
|
| 109 |
+
return out
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def benchmark_prompt_stats() -> dict[str, dict[str, float]]:
|
| 113 |
+
stats: dict[str, dict[str, float]] = {}
|
| 114 |
+
for key, (path, getter) in HF_SOURCES.items():
|
| 115 |
+
ds = load_dataset(path, split="test")
|
| 116 |
+
prompts = [str(p).strip() for p in getter(ds) if str(p).strip()]
|
| 117 |
+
stats[key] = {
|
| 118 |
+
"count": float(len(prompts)),
|
| 119 |
+
"avg_words": float(mean(len(p.split()) for p in prompts)),
|
| 120 |
+
}
|
| 121 |
+
return stats
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def main() -> None:
|
| 125 |
+
judge = parse_alignment(SRC)
|
| 126 |
+
prompt_stats = benchmark_prompt_stats()
|
| 127 |
+
|
| 128 |
+
rows = []
|
| 129 |
+
for key, meta in BENCHMARKS.items():
|
| 130 |
+
if key not in judge:
|
| 131 |
+
continue
|
| 132 |
+
avg_score = mean(judge[key].values()) / meta["score_max"]
|
| 133 |
+
rows.append({
|
| 134 |
+
"key": key,
|
| 135 |
+
"display": meta["display"],
|
| 136 |
+
"x": prompt_stats[key]["avg_words"],
|
| 137 |
+
"y": avg_score,
|
| 138 |
+
"size": prompt_stats[key]["count"],
|
| 139 |
+
})
|
| 140 |
+
|
| 141 |
+
# Pastel colors keyed by avg prompt-length bucket.
|
| 142 |
+
def bucket_color(x: float) -> str:
|
| 143 |
+
if x < 100:
|
| 144 |
+
return "#A8D5FF" # short prompts (light blue)
|
| 145 |
+
if x <= 500:
|
| 146 |
+
return "#FFD6A5" # medium prompts (light orange)
|
| 147 |
+
return "#FFADAD" # long prompts (light red)
|
| 148 |
+
|
| 149 |
+
fig, ax = plt.subplots(figsize=(7.6, 4.0))
|
| 150 |
+
|
| 151 |
+
sizes = np.array([r["size"] for r in rows])
|
| 152 |
+
# Map prompt count -> marker area (points^2).
|
| 153 |
+
s_min, s_max = 600.0, 4200.0
|
| 154 |
+
if sizes.max() > sizes.min():
|
| 155 |
+
size_norm = (sizes - sizes.min()) / (sizes.max() - sizes.min())
|
| 156 |
+
else:
|
| 157 |
+
size_norm = np.zeros_like(sizes, dtype=float)
|
| 158 |
+
marker_areas = s_min + size_norm * (s_max - s_min)
|
| 159 |
+
|
| 160 |
+
for r, area in zip(rows, marker_areas, strict=False):
|
| 161 |
+
ax.scatter(
|
| 162 |
+
r["x"], r["y"],
|
| 163 |
+
s=area,
|
| 164 |
+
facecolor=bucket_color(r["x"]),
|
| 165 |
+
edgecolor="white",
|
| 166 |
+
linewidth=1.2,
|
| 167 |
+
alpha=0.9,
|
| 168 |
+
zorder=3,
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
for r, area in zip(rows, marker_areas, strict=False):
|
| 172 |
+
radius_pts = np.sqrt(area / np.pi)
|
| 173 |
+
style = LABEL_STYLE.get(r["key"], {})
|
| 174 |
+
fontsize = style.get("fontsize", 11)
|
| 175 |
+
ha = style.get("ha", "center")
|
| 176 |
+
va = style.get("va", "auto")
|
| 177 |
+
dx = style.get("dx", 0)
|
| 178 |
+
dy = style.get("dy", 0)
|
| 179 |
+
# va="auto" places the label just above the bubble's edge.
|
| 180 |
+
if va == "auto":
|
| 181 |
+
xytext = (dx, dy + radius_pts + 6)
|
| 182 |
+
va_final = "bottom"
|
| 183 |
+
else:
|
| 184 |
+
xytext = (dx, dy)
|
| 185 |
+
va_final = va
|
| 186 |
+
ax.annotate(
|
| 187 |
+
r["display"],
|
| 188 |
+
xy=(r["x"], r["y"]),
|
| 189 |
+
xytext=xytext,
|
| 190 |
+
textcoords="offset points",
|
| 191 |
+
ha=ha, va=va_final,
|
| 192 |
+
fontsize=fontsize,
|
| 193 |
+
zorder=4,
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
ax.set_xscale("log")
|
| 197 |
+
ax.set_ylabel("Score", fontsize=15)
|
| 198 |
+
ax.tick_params(axis="both", labelsize=13)
|
| 199 |
+
ax.grid(True, which="major", linestyle="--", linewidth=0.5, alpha=0.5, zorder=1)
|
| 200 |
+
for boundary in (100, 500):
|
| 201 |
+
ax.axvline(boundary, color="black", linestyle=(0, (10, 8)),
|
| 202 |
+
linewidth=1.0, alpha=0.85, zorder=2)
|
| 203 |
+
from matplotlib.ticker import FixedLocator, NullLocator
|
| 204 |
+
ax.xaxis.set_minor_locator(NullLocator())
|
| 205 |
+
ax.xaxis.set_major_locator(FixedLocator([10, 100, 500]))
|
| 206 |
+
ax.xaxis.set_major_formatter(plt.FuncFormatter(lambda v, _: f"{int(v)}"))
|
| 207 |
+
for side in ("top", "left", "right"):
|
| 208 |
+
ax.spines[side].set_visible(False)
|
| 209 |
+
|
| 210 |
+
xs = np.array([r["x"] for r in rows])
|
| 211 |
+
ys = np.array([r["y"] for r in rows])
|
| 212 |
+
ax.set_xlim(xs.min() * 0.55, xs.max() * 3.0)
|
| 213 |
+
pad = 0.02 * (ys.max() - ys.min() + 1e-9)
|
| 214 |
+
ax.set_ylim(ys.min() - pad - 0.02, ys.max() + pad + 0.04)
|
| 215 |
+
|
| 216 |
+
# Bucket labels centered (geometric mean) inside each region, sitting just
|
| 217 |
+
# above the x-axis. Color each label with its bucket's bubble color
|
| 218 |
+
# (slightly darkened for legibility against the white background).
|
| 219 |
+
xlo, xhi = ax.get_xlim()
|
| 220 |
+
bucket_centers = [
|
| 221 |
+
("short", np.sqrt(xlo * 100), "#3A8DDE", "bottom"), # darker blue, below
|
| 222 |
+
("medium", np.sqrt(100 * 500), "#E59837", "top"), # darker orange, above
|
| 223 |
+
("long", np.sqrt(500 * xhi), "#D94F4F", "top"), # darker red, above
|
| 224 |
+
]
|
| 225 |
+
trans = ax.get_xaxis_transform() # x in data coords, y in axes fraction
|
| 226 |
+
for label, x_center, color, position in bucket_centers:
|
| 227 |
+
if position == "bottom":
|
| 228 |
+
y_frac, va = 0.04, "bottom"
|
| 229 |
+
else:
|
| 230 |
+
y_frac, va = 0.96, "top"
|
| 231 |
+
ax.text(
|
| 232 |
+
x_center, y_frac, label,
|
| 233 |
+
transform=trans,
|
| 234 |
+
ha="center", va=va,
|
| 235 |
+
fontsize=14,
|
| 236 |
+
color=color,
|
| 237 |
+
family=["Comic Sans MS", "Chalkboard SE", "DejaVu Sans"],
|
| 238 |
+
fontweight="bold",
|
| 239 |
+
zorder=5,
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
fig.tight_layout()
|
| 243 |
+
out_png = ROOT / "benchmark_overview.png"
|
| 244 |
+
out_pdf = ROOT / "benchmark_overview.pdf"
|
| 245 |
+
fig.savefig(out_png, dpi=200)
|
| 246 |
+
fig.savefig(out_pdf)
|
| 247 |
+
print(f"saved {out_png}")
|
| 248 |
+
print(f"saved {out_pdf}")
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
if __name__ == "__main__":
|
| 252 |
+
main()
|
figures/gemini_figures/_gen.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate 5 nano banana images for prompt.json keys, save into same dir."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import time
|
| 8 |
+
from io import BytesIO
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from google import genai
|
| 13 |
+
from google.genai import types
|
| 14 |
+
|
| 15 |
+
HERE = Path(__file__).parent
|
| 16 |
+
PROMPTS = json.loads((HERE / "prompt.json").read_text())
|
| 17 |
+
MODEL = "gemini-2.5-flash-image"
|
| 18 |
+
|
| 19 |
+
SAFETY = [
|
| 20 |
+
types.SafetySetting(category=c, threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH)
|
| 21 |
+
for c in (
|
| 22 |
+
types.HarmCategory.HARM_CATEGORY_HARASSMENT,
|
| 23 |
+
types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
| 24 |
+
types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
| 25 |
+
types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
| 26 |
+
)
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def gen(client, key: str, prompt: str) -> bool:
|
| 31 |
+
target = HERE / f"{key}.png"
|
| 32 |
+
cfg = types.GenerateContentConfig(
|
| 33 |
+
response_modalities=["TEXT", "IMAGE"],
|
| 34 |
+
safety_settings=SAFETY,
|
| 35 |
+
)
|
| 36 |
+
for attempt in range(8):
|
| 37 |
+
try:
|
| 38 |
+
r = client.models.generate_content(model=MODEL, contents=[prompt], config=cfg)
|
| 39 |
+
for part in (r.parts or []):
|
| 40 |
+
if part.inline_data is not None:
|
| 41 |
+
Image.open(BytesIO(part.inline_data.data)).convert("RGB").save(target)
|
| 42 |
+
print(f" OK {key} -> {target.name}")
|
| 43 |
+
return True
|
| 44 |
+
except Exception as e: # noqa: BLE001
|
| 45 |
+
print(f" attempt {attempt+1} fail {key}: {str(e)[:120]}")
|
| 46 |
+
time.sleep(1 + attempt)
|
| 47 |
+
print(f" GAVE UP {key}")
|
| 48 |
+
return False
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def main():
|
| 52 |
+
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 53 |
+
if not api_key:
|
| 54 |
+
sys.exit("set GOOGLE_API_KEY")
|
| 55 |
+
client = genai.Client(api_key=api_key)
|
| 56 |
+
for k, p in PROMPTS.items():
|
| 57 |
+
print(f"[{k}] generating ...")
|
| 58 |
+
gen(client, k, p)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
if __name__ == "__main__":
|
| 62 |
+
main()
|
figures/gemini_figures/_gen2.py
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate 5 nano banana 2 (gemini-3-pro-image) images, save with _v2 suffix."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import time
|
| 8 |
+
from io import BytesIO
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from google import genai
|
| 13 |
+
from google.genai import types
|
| 14 |
+
|
| 15 |
+
HERE = Path(__file__).parent
|
| 16 |
+
PROMPTS = json.loads((HERE / "prompt.json").read_text())
|
| 17 |
+
MODEL = "gemini-3-pro-image-preview"
|
| 18 |
+
|
| 19 |
+
SAFETY = [
|
| 20 |
+
types.SafetySetting(category=c, threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH)
|
| 21 |
+
for c in (
|
| 22 |
+
types.HarmCategory.HARM_CATEGORY_HARASSMENT,
|
| 23 |
+
types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
| 24 |
+
types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
| 25 |
+
types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
| 26 |
+
)
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def gen(client, key: str, prompt: str) -> bool:
|
| 31 |
+
target = HERE / f"{key}_v2.png"
|
| 32 |
+
cfg = types.GenerateContentConfig(
|
| 33 |
+
response_modalities=["TEXT", "IMAGE"],
|
| 34 |
+
safety_settings=SAFETY,
|
| 35 |
+
)
|
| 36 |
+
for attempt in range(8):
|
| 37 |
+
try:
|
| 38 |
+
r = client.models.generate_content(model=MODEL, contents=[prompt], config=cfg)
|
| 39 |
+
for part in (r.parts or []):
|
| 40 |
+
if part.inline_data is not None:
|
| 41 |
+
Image.open(BytesIO(part.inline_data.data)).convert("RGB").save(target)
|
| 42 |
+
print(f" OK {key} -> {target.name}")
|
| 43 |
+
return True
|
| 44 |
+
txts = " ".join(getattr(p, "text", "") or "" for p in (r.parts or []))
|
| 45 |
+
print(f" attempt {attempt+1} no_image {key}: {txts[:120]}")
|
| 46 |
+
except Exception as e: # noqa: BLE001
|
| 47 |
+
print(f" attempt {attempt+1} fail {key}: {str(e)[:120]}")
|
| 48 |
+
time.sleep(1 + attempt)
|
| 49 |
+
print(f" GAVE UP {key}")
|
| 50 |
+
return False
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def main():
|
| 54 |
+
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 55 |
+
if not api_key:
|
| 56 |
+
sys.exit("set GOOGLE_API_KEY")
|
| 57 |
+
client = genai.Client(api_key=api_key)
|
| 58 |
+
print(f"model={MODEL}")
|
| 59 |
+
for k, p in PROMPTS.items():
|
| 60 |
+
print(f"[{k}] generating ...")
|
| 61 |
+
gen(client, k, p)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
if __name__ == "__main__":
|
| 65 |
+
main()
|
figures/gemini_figures/_gen_p2.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate 5 nano banana (gemini-2.5-flash-image) images for prompt2.json, 1024x1024."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import time
|
| 8 |
+
from io import BytesIO
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from google import genai
|
| 13 |
+
from google.genai import types
|
| 14 |
+
|
| 15 |
+
HERE = Path(__file__).parent
|
| 16 |
+
PROMPTS = json.loads((HERE / "prompt2.json").read_text())
|
| 17 |
+
MODEL = "gemini-2.5-flash-image"
|
| 18 |
+
|
| 19 |
+
SAFETY = [
|
| 20 |
+
types.SafetySetting(category=c, threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH)
|
| 21 |
+
for c in (
|
| 22 |
+
types.HarmCategory.HARM_CATEGORY_HARASSMENT,
|
| 23 |
+
types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
| 24 |
+
types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
| 25 |
+
types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
| 26 |
+
)
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def gen(client, key: str, prompt: str) -> bool:
|
| 31 |
+
target = HERE / f"{key}_p2.png"
|
| 32 |
+
cfg = types.GenerateContentConfig(
|
| 33 |
+
response_modalities=["TEXT", "IMAGE"],
|
| 34 |
+
safety_settings=SAFETY,
|
| 35 |
+
)
|
| 36 |
+
for attempt in range(8):
|
| 37 |
+
try:
|
| 38 |
+
r = client.models.generate_content(model=MODEL, contents=[prompt], config=cfg)
|
| 39 |
+
for part in (r.parts or []):
|
| 40 |
+
if part.inline_data is not None:
|
| 41 |
+
img = Image.open(BytesIO(part.inline_data.data)).convert("RGB")
|
| 42 |
+
if img.size != (1024, 1024):
|
| 43 |
+
img = img.resize((1024, 1024), Image.LANCZOS)
|
| 44 |
+
img.save(target)
|
| 45 |
+
print(f" OK {key} -> {target.name} size={img.size}")
|
| 46 |
+
return True
|
| 47 |
+
except Exception as e: # noqa: BLE001
|
| 48 |
+
print(f" attempt {attempt+1} fail {key}: {str(e)[:120]}")
|
| 49 |
+
time.sleep(1 + attempt)
|
| 50 |
+
print(f" GAVE UP {key}")
|
| 51 |
+
return False
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def main():
|
| 55 |
+
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 56 |
+
if not api_key:
|
| 57 |
+
sys.exit("set GOOGLE_API_KEY")
|
| 58 |
+
client = genai.Client(api_key=api_key)
|
| 59 |
+
print(f"model={MODEL}")
|
| 60 |
+
for k, p in PROMPTS.items():
|
| 61 |
+
print(f"[{k}] generating ...")
|
| 62 |
+
gen(client, k, p)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
main()
|
figures/gemini_figures/_gen_p3.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate 5 nano banana (gemini-2.5-flash-image) images for prompt3.json, 1024x1024."""
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import json
|
| 5 |
+
import os
|
| 6 |
+
import sys
|
| 7 |
+
import time
|
| 8 |
+
from io import BytesIO
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from PIL import Image
|
| 12 |
+
from google import genai
|
| 13 |
+
from google.genai import types
|
| 14 |
+
|
| 15 |
+
HERE = Path(__file__).parent
|
| 16 |
+
PROMPTS = json.loads((HERE / "prompt3.json").read_text())
|
| 17 |
+
MODEL = "gemini-2.5-flash-image"
|
| 18 |
+
|
| 19 |
+
SAFETY = [
|
| 20 |
+
types.SafetySetting(category=c, threshold=types.HarmBlockThreshold.BLOCK_ONLY_HIGH)
|
| 21 |
+
for c in (
|
| 22 |
+
types.HarmCategory.HARM_CATEGORY_HARASSMENT,
|
| 23 |
+
types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
| 24 |
+
types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
| 25 |
+
types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
| 26 |
+
)
|
| 27 |
+
]
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def gen(client, key: str, prompt: str) -> bool:
|
| 31 |
+
target = HERE / f"{key}_p3.png"
|
| 32 |
+
cfg = types.GenerateContentConfig(
|
| 33 |
+
response_modalities=["TEXT", "IMAGE"],
|
| 34 |
+
safety_settings=SAFETY,
|
| 35 |
+
)
|
| 36 |
+
for attempt in range(8):
|
| 37 |
+
try:
|
| 38 |
+
r = client.models.generate_content(model=MODEL, contents=[prompt], config=cfg)
|
| 39 |
+
for part in (r.parts or []):
|
| 40 |
+
if part.inline_data is not None:
|
| 41 |
+
img = Image.open(BytesIO(part.inline_data.data)).convert("RGB")
|
| 42 |
+
if img.size != (1024, 1024):
|
| 43 |
+
img = img.resize((1024, 1024), Image.LANCZOS)
|
| 44 |
+
img.save(target)
|
| 45 |
+
print(f" OK {key} -> {target.name} size={img.size}")
|
| 46 |
+
return True
|
| 47 |
+
except Exception as e: # noqa: BLE001
|
| 48 |
+
print(f" attempt {attempt+1} fail {key}: {str(e)[:120]}")
|
| 49 |
+
time.sleep(1 + attempt)
|
| 50 |
+
print(f" GAVE UP {key}")
|
| 51 |
+
return False
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def main():
|
| 55 |
+
api_key = os.getenv("GOOGLE_API_KEY") or os.getenv("GEMINI_API_KEY")
|
| 56 |
+
if not api_key:
|
| 57 |
+
sys.exit("set GOOGLE_API_KEY")
|
| 58 |
+
client = genai.Client(api_key=api_key)
|
| 59 |
+
print(f"model={MODEL}")
|
| 60 |
+
for k, p in PROMPTS.items():
|
| 61 |
+
print(f"[{k}] generating ...")
|
| 62 |
+
gen(client, k, p)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
if __name__ == "__main__":
|
| 66 |
+
main()
|
figures/gemini_figures/attribute.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/attribute_p2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/attribute_p3.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/attribute_v2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/balance.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/balance_p2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/balance_p3.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/balance_v2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/entity.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/entity_p2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/entity_p3.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/entity_v2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/origin.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/origin_p2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/origin_p3.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/origin_v2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/prompt.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"origin": "A gopher standing on its hind legs in a lush, green meadow, facing the camera with its front paws held together.",
|
| 3 |
+
"balance": "A gray-furred gopher with distinct white facial markings stands upright on its hind legs atop a patch of short, vibrant green grass in a sunlit meadow. The animal's front paws are clasped tightly together at chest level, while its small, rounded ears protrude symmetrically from the sides of its head. Surrounding the gopher, tall wildflowers with yellow and purple petals rise vertically from the soil, their stems leaning slightly against the breeze. A large, weathered oak tree trunk anchors the background directly behind the creature, its rough, dark bark contrasting with the soft texture of the meadow floor. Scattered brown pinecones lie horizontally on the ground near the gopher's feet, partially buried in the grass. A shallow stream of clear water flows diagonally across the lower left quadrant of the scene, reflecting the sky above. The gopher's black eyes are positioned forward, gazing directly toward the viewer, while its short tail remains tucked against its rear legs. Overhead, a few white clouds drift slowly across a pale blue sky, casting soft, shifting shadows across the uneven terrain where the gopher maintains its stationary posture.",
|
| 4 |
+
"entity": "A gopher stands on hind legs within a meadow, facing the camera with front paws held together near its chest. The gopher is surrounded by a dense cluster of wildflowers, including daisies, clover, and buttercups, interspersed with tall blades of grass and patches of moss. A small wooden fence runs horizontally behind the gopher, constructed from vertical posts and horizontal rails, with a weathered sign attached to the central post displaying the text 'ZONE 4'. Several rabbits graze near the fence base, while a squirrel perches on a low branch of a nearby oak tree. A blue jay sits on a stone marker to the left, next to a small metal watering can lying on its side. Scattered across the ground are acorns, dried leaves, and a discarded red ribbon. In the background, a wooden barn with a corrugated metal roof stands behind a row of pine trees, with a windmill visible on the horizon. A dirt path winds through the grass, leading toward a stone well with a rope hanging from its pulley. A bicycle leans against a tree trunk nearby, its tires partially buried in the soft earth. Clouds drift above the scene, casting shadows across the meadow floor where a small stream flows under a fallen log.",
|
| 5 |
+
"attribute": "A single adult gopher with coarse, mottled brown and gray fur stands rigidly on two thick, clawed hind legs within a dense, low-lying meadow. The gopher's small, rounded ears are pinned slightly back against its skull, while its dark, bead-like eyes reflect the ambient sky, and its short, black nose twitches above a mouth held shut. Its front paws, covered in shorter, lighter tan fur with visible dark claws, are pressed tightly together at chest level, fingers interlocked. The surrounding meadow consists entirely of individual blades of grass varying in height from two to six inches, displaying a spectrum of green hues from deep emerald to pale lime, with some blades bearing translucent water droplets and others showing slight yellowing at the tips. The soil beneath the gopher's feet is a compacted mix of dark brown earth and scattered small, gray pebbles. Sunlight strikes the scene from the upper left, casting distinct, elongated shadows of the grass blades and the gopher's body onto the ground, highlighting the texture of the fur and the moisture on the vegetation without introducing any atmospheric haze or artistic stylization.",
|
| 6 |
+
"relation": "A gopher stands vertically on its hind legs, with its lower limbs firmly planted on the soil surface of a meadow, while its upper torso extends upward into the air. The gopher's front paws are pressed together at chest level, creating a closed loop where the digits of the left paw interlock with the digits of the right paw. Surrounding the gopher's feet, individual blades of green grass emerge from the earth, with some stalks leaning against the gopher's ankles and others bending under the weight of the gopher's body. The gopher's head is positioned directly above the torso, facing forward, with its ears protruding laterally from the sides of the skull. Behind the gopher, a dense cluster of grass forms a continuous vertical barrier, with individual stems overlapping one another to create a multi-layered texture. The gopher's nose is located at the frontmost point of its face, protruding slightly beyond the plane of its eyes. The ground beneath the gopher is uneven, with small mounds of dirt supporting the gopher's weight and depressions forming around the base of the grass stalks. The gopher's tail rests against the back of its hind legs, curving slightly to maintain balance. The spatial arrangement places the gopher centrally within the frame, with the grass extending outward in all directions from the gopher's position, creating a radial distribution of vegetation."
|
| 7 |
+
}
|
figures/gemini_figures/prompt2.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"origin": "A white ptarmigan with a red patch on its head and chest stands on a patch of snow in a field of dried grass, facing left.",
|
| 3 |
+
"balance": "A white ptarmigan with dense, fluffy plumage and a distinct crimson patch covering its crown and upper chest stands firmly on a compacted mound of snow situated within a sprawling field of brittle, golden-brown dried grass. The bird faces strictly left, its black beak aligned parallel to the horizon, while its dark, round eye reflects the ambient light. Surrounding the central snow patch, individual stalks of grass lean at various angles, some buried beneath the snow's edge and others rising sharply above it. A thin layer of frost coats the tips of the nearest grass blades, creating a sharp textural contrast against the smooth, undisturbed surface of the snow mound. The ptarmigan's feathered feet are partially submerged in the snow, gripping the icy substrate, while its tail feathers fan slightly behind it, casting a soft, elongated shadow onto the snow to the right. In the immediate background, a cluster of frozen twigs protrudes from the grass, positioned three feet behind the bird, and a small pile of scattered seeds rests on the snow near the bird's left foot. The entire scene is defined by the rigid spatial relationship between the standing bird, the supporting snow mound, and the encroaching field of dried vegetation, with no elements overlapping in a way that obscures their distinct boundaries.",
|
| 4 |
+
"entity": "A white ptarmigan with a red patch on its head and chest stands on a patch of snow in a field of dried grass, facing left, surrounded by scattered pinecones, fallen acorns, and small twigs. Near the bird's feet lie three distinct feathers, a broken beetle shell, and a cluster of frost-covered lichen. Behind the ptarmigan, a weathered log rests horizontally, supporting a pile of dry moss, a single red berry, and a shard of ice. To the left, a stone outcrop displays cracks filled with gray lichen, while a small tuft of green moss grows at its base. Further back, a cluster of dried grass stalks sways, interspersed with fallen leaves, a moth wing, and a piece of bark. A shallow puddle reflects the sky, bordered by pebbles, a rusted nail, and a fragment of bone. Above, a low-hanging cloud casts shadows on a nearby rock, a patch of clover, and a cluster of wild thistle. In the distance, a fence post stands beside a tangled vine, a discarded bottle cap, and a small pile of ash. The scene includes a fallen branch, a cluster of mushrooms, a spider web, a piece of glass, and a small bird's nest, all arranged across the terrain with overlapping layers of snow, grass, and debris.",
|
| 5 |
+
"attribute": "A single white ptarmigan stands stationary on a compacted patch of granular snow within a field of desiccated, golden-brown grass stalks. The bird's plumage consists of dense, overlapping feathers with a matte, non-reflective surface texture, featuring a distinct, irregular crimson patch covering the crown and extending down the anterior thorax. Its beak is short, conical, and dark grey, positioned in a closed state. The legs are short, scaly, and pale pink, ending in four forward-facing toes covered in white feather tufts that blend with the surrounding snow. The bird faces strictly left, with its head rotated slightly downward. The snow patch exhibits a rough, crystalline surface with minor indentations from the bird's feet and scattered, fine ice shards reflecting diffuse ambient light. Surrounding the snow are upright, brittle grass stems, some bent by wind, displaying a dry, fibrous texture and varying shades of tan and straw. The ground beneath the grass is dark brown earth, partially visible through gaps in the vegetation. No other animals or artificial objects are present in the immediate vicinity, creating a sparse composition focused entirely on the detailed physical interaction between the feathered avian subject and the frozen, vegetated terrain.",
|
| 6 |
+
"relation": "A white ptarmigan with a red patch on its head and chest stands on a patch of snow in a field of dried grass, facing left, where its talons grip the icy surface while snowflakes accumulate between its feathers and the ground. The bird's body leans slightly forward, causing its tail feathers to rest against a cluster of dried grass stems that rise vertically from the snow beneath it. A single blade of grass pierces through the snow layer directly behind the ptarmigan's left wing, connecting the ground to the mid-air space near its back. The red patch on its chest overlaps with a shadow cast by its own head, which extends onto the snow to the left. Snow particles bridge the gap between the bird's feet and the surrounding grass, creating a continuous chain of frozen matter. The field of dried grass surrounds the snow patch in concentric rings, with some stalks bending under the weight of accumulated snow, pressing against the bird's lower legs. A small mound of snow sits directly beneath the ptarmigan's beak, forming a physical barrier between its mouth and the grass below. The spatial arrangement creates a layered structure where the bird is embedded within the intersection of snow, grass, and air, with every element physically touching or supporting another in a tightly interlocked network."
|
| 7 |
+
}
|
figures/gemini_figures/prompt3.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"origin": "A family of three, consisting of a man, a woman, and a young child, engaged in a playful martial arts demonstration in a modern, well-lit bedroom.",
|
| 3 |
+
"balance": "A man wearing a loose gray cotton t-shirt and dark denim jeans stands on a polished oak floor, his left foot planted firmly while his right leg extends in a controlled high kick. Directly opposite him, a woman in a white linen blouse and black trousers adopts a defensive stance, her forearms crossed to block the incoming motion. Between them, a young child in a bright red hoodie and blue shorts mimics the woman's posture, standing slightly behind her right shoulder with small fists raised. The trio occupies the center of a modern bedroom where a large wooden bed with a white duvet rests against the far wall, positioned parallel to a floor-to-ceiling window that floods the room with natural light. A low glass coffee table sits in front of the bed, holding a stack of hardcover books and a ceramic vase. To the left of the man, a tall bookshelf filled with colorful spines reaches the ceiling, while a small potted fern sits on the windowsill between the glass panes. The spatial arrangement places the family in a triangular formation, with the child bridging the gap between the adults, all grounded on the wooden surface beneath the ambient daylight filtering through the sheer curtains.",
|
| 4 |
+
"entity": "A man, a woman, and a young child execute synchronized martial arts forms on a hardwood floor within a modern bedroom. The man wears a white gi, black belt, and wrist wraps while blocking a wooden practice sword held by the woman, who wears a red gi, headband, and shin guards. The young child, dressed in a blue gi and knee pads, mimics a low stance near a stack of folded towels and a yoga mat. A large window with sheer curtains frames the scene, casting natural light across a nightstand holding a digital clock, a glass of water, and a small potted plant. Behind the family, a wooden wardrobe stands beside a metal clothing rack draped with jackets and scarves. A plush rug covers part of the floor near a toy box overflowing with plastic blocks, action figures, and a stuffed bear. On the wall, a framed photograph, a calendar, and a string of paper lanterns hang above a bookshelf filled with hardcover books, a globe, and a model airplane. A ceiling fan with four blades rotates slowly above a hanging mobile of wooden stars. A laptop sits open on a desk in the corner next to a pair of headphones, a notebook, and a pen, while a laundry basket filled with clothes rests near the door.",
|
| 5 |
+
"attribute": "A man with short dark hair, wearing a white cotton t-shirt with visible weave texture and grey sweatpants featuring elastic cuffs, stands on a polished oak floor with his left foot forward and right arm extended in a high block position. Beside him, a woman with long brown hair tied in a loose ponytail wears a red ribbed knit sweater with frayed cuffs and blue denim jeans showing faded knee patches; her right leg is bent at a forty-five-degree angle while her left hand forms a fist near her chest. Between them, a young child with curly blonde hair wears a yellow striped polo shirt with a small stain on the collar and green cargo shorts with multiple zipped pockets; the child's arms are raised in a defensive stance, fingers splayed, standing on a beige wool rug with a frayed edge. The room contains a wooden bed frame with a metal headboard positioned against a white painted drywall, next to a nightstand made of light maple wood holding a ceramic lamp with a fabric shade. Sunlight streams through a rectangular window with clear glass panes, casting sharp linear shadows across the floorboards, while a silver ceiling fan with four blades rotates slowly above the group, its metallic surface reflecting the ambient light.",
|
| 6 |
+
"relation": "A man, a woman, and a young child occupy a modern bedroom where the man stands with feet planted on a rug, his left arm extended to intercept the woman's raised right fist hovering inches from his shoulder. The woman balances on the balls of her feet atop the same rug, her body leaning forward at a sharp angle relative to the man's upright posture, while her left hand grips the child's wrist. The child, suspended mid-air by the woman's grip, has legs bent and feet dangling directly above the man's knee, creating a triangular spatial configuration between the three figures. The man's right hand reaches upward to support the child's ankle, forming a closed loop of physical contact. Behind them, a wooden bed frame runs parallel to the wall, with a mattress resting on slats that intersect the room's floor plane. A bedside lamp sits on a table adjacent to the bed, casting a cone of light that overlaps the man's torso and the child's legs. The rug lies flat on the floorboards, its edges abutting the bed frame, while a window on the far wall allows external light to stream across the floor, intersecting the shadows cast by the trio. The spatial arrangement creates a dense network of supports and intersections, with limbs crossing and bodies offset to form a complex, interlocking structure within the confined room dimensions."
|
| 7 |
+
}
|
figures/gemini_figures/relation.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/relation_p2.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/relation_p3.png
ADDED
|
Git LFS Details
|
figures/gemini_figures/relation_v2.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/flux2_base.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/flux2_lora_clip.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/flux2_lora_hpsv3.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/flux2_lora_unified_9b.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/flux2_lora_vqa_balance.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/zimage_base.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/zimage_lora_clip.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/zimage_lora_hpsv3.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/zimage_lora_unified_9b.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/01_aesthetic_photo/zimage_lora_vqa_balance_30st.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/02_art_nouveau/flux2_base.png
ADDED
|
Git LFS Details
|
figures/portrait_compare/02_art_nouveau/flux2_lora_clip.png
ADDED
|
Git LFS Details
|