File size: 9,961 Bytes
a4a3dbb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
import textwrap


ROOT = Path(__file__).resolve().parents[1]
OUT_DIRS = [
    ROOT / "doc" / "assets",
    ROOT / "out" / "proposal_materials" / "assets",
]

FONT_CANDIDATES = [
    "/System/Library/Fonts/STHeiti Medium.ttc",
    "/System/Library/Fonts/Hiragino Sans GB.ttc",
    "/System/Library/Fonts/Supplemental/Arial Unicode.ttf",
    "/System/Library/Fonts/Helvetica.ttc",
]


def font(size, bold=False):
    for p in FONT_CANDIDATES:
        if Path(p).exists():
            return ImageFont.truetype(p, size=size)
    return ImageFont.load_default()


F_TITLE = font(42)
F_SUBTITLE = font(25)
F_HEAD = font(24)
F_BODY = font(21)
F_SMALL = font(18)


def text_size(draw, text, fnt):
    box = draw.textbbox((0, 0), text, font=fnt)
    return box[2] - box[0], box[3] - box[1]


def wrap_text(text, width_chars):
    lines = []
    for paragraph in text.split("\n"):
        if not paragraph:
            lines.append("")
            continue
        lines.extend(textwrap.wrap(paragraph, width=width_chars, break_long_words=False))
    return lines


def draw_wrapped(draw, xy, text, fnt, fill, width_chars, line_gap=7):
    x, y = xy
    for line in wrap_text(text, width_chars):
        draw.text((x, y), line, font=fnt, fill=fill)
        y += text_size(draw, line or " ", fnt)[1] + line_gap
    return y


def round_rect(draw, box, radius, fill, outline=None, width=2):
    draw.rounded_rectangle(box, radius=radius, fill=fill, outline=outline, width=width)


def arrow(draw, start, end, fill=(60, 70, 90), width=4):
    draw.line([start, end], fill=fill, width=width)
    x1, y1 = start
    x2, y2 = end
    if abs(x2 - x1) >= abs(y2 - y1):
        direction = 1 if x2 >= x1 else -1
        pts = [(x2, y2), (x2 - 16 * direction, y2 - 9), (x2 - 16 * direction, y2 + 9)]
    else:
        direction = 1 if y2 >= y1 else -1
        pts = [(x2, y2), (x2 - 9, y2 - 16 * direction), (x2 + 9, y2 - 16 * direction)]
    draw.polygon(pts, fill=fill)


def save_all(img, name):
    for d in OUT_DIRS:
        d.mkdir(parents=True, exist_ok=True)
        img.save(d / name)


def build_literature_bridge():
    W, H = 1800, 1320
    img = Image.new("RGB", (W, H), "white")
    d = ImageDraw.Draw(img)
    bg = (247, 249, 252)
    img.paste(bg, [0, 0, W, H])
    d.text((70, 50), "文献方法如何支撑本项目方法设计", font=F_TITLE, fill=(20, 30, 45))
    d.text((72, 105), "不直接复制论文原图;根据方法部分重画为 proposal 专用方法映射图", font=F_SUBTITLE, fill=(90, 100, 115))

    cols = [70, 635, 1210]
    widths = [500, 500, 500]
    y0 = 175
    headers = ["已阅读/核对的文献线索", "论文中的方法思想", "本项目采用的模块"]
    colors = [(232, 241, 255), (235, 248, 241), (255, 244, 229)]
    for x, w, h, c in zip(cols, widths, headers, colors):
        round_rect(d, (x, y0, x + w, y0 + 70), 18, c, outline=(195, 205, 220))
        tw, th = text_size(d, h, F_HEAD)
        d.text((x + (w - tw) / 2, y0 + 21), h, font=F_HEAD, fill=(25, 40, 60))

    rows = [
        (
            "T2V-CompBench\nGeckoNum\nT2ICountBench\nDemystifying Numerosity",
            "数值/计数能力可单独评测;prompt refinement 不可靠;显式 layout/noise guidance 和自动 reward 有效。",
            "把普通数字从 prompt 中拆出来,设计 quantity-specific numerical token vocabulary,并用可测代理量评估。",
        ),
        (
            "Textual Inversion",
            "冻结生成模型,用少量图像学习新的 pseudo-word embedding,使新概念可被 prompt 调用。",
            "学习物理量 token / anchor token;token 表示数值区间、倍率和单位类型,而不是人物/物体/风格。",
        ),
        (
            "QuantiPhy\nPhysQuantAgent\nGuidedSceneGen",
            "物理量估计需要尺度、几何和视觉锚点;VLM 数值判断会有 qualitative 与 quantitative gap。",
            "第二阶段做 unit-anchor calibration;用液面、轨迹、亮度、OCR、几何测量替代纯 VLM judge。",
        ),
        (
            "DenseDPO\nHuViDPO\nGPO",
            "DPO/LoRA 可用于视频后训练;segment-level preference 更适合动态视频;groupwise ranking 信息密度高。",
            "用 groupwise preference 学 1<2<4<8;动态量采用 segment reward;LoRA/adapter 降低训练成本。",
        ),
        (
            "DiffPhy\nPhysVideoGenerator\nWan/Hunyuan/LongCat",
            "物理上下文、latent physical tokens 和开放 video foundation models 可作为训练与推理基础。",
            "以 Wan/Hunyuan/LongCat 为 baseline;引入物理上下文和 quantity token 条件,但核心创新聚焦单位量 grounding。",
        ),
    ]

    row_h = 164
    y = y0 + 95
    for idx, row in enumerate(rows):
        fill = (255, 255, 255) if idx % 2 == 0 else (252, 253, 255)
        for x, w in zip(cols, widths):
            round_rect(d, (x, y, x + w, y + row_h), 18, fill, outline=(215, 222, 232))
        for col_idx, text in enumerate(row):
            x = cols[col_idx] + 25
            if col_idx == 0:
                draw_wrapped(d, (x, y + 28), text, F_BODY, (35, 62, 112), 26, 8)
            else:
                draw_wrapped(d, (x, y + 24), text, F_BODY, (45, 55, 70), 32, 8)
        arrow(d, (cols[0] + widths[0] + 12, y + row_h // 2), (cols[1] - 12, y + row_h // 2))
        arrow(d, (cols[1] + widths[1] + 12, y + row_h // 2), (cols[2] - 12, y + row_h // 2))
        y += row_h + 24

    d.text((70, H - 70), "结论:这些论文不是直接解决 physical unit quantity video generation,但分别支撑“数值 token 化、相对偏好训练、单位锚定、自动评测”的设计。", font=F_SMALL, fill=(80, 90, 105))
    save_all(img, "literature_method_bridge_zh.png")


def build_pipeline():
    W, H = 1800, 1200
    img = Image.new("RGB", (W, H), (248, 250, 252))
    d = ImageDraw.Draw(img)
    d.text((70, 50), "本项目方法:Quantity Token → Relative Training → Unit Anchor", font=F_TITLE, fill=(20, 30, 45))
    d.text((72, 106), "目标:把物理数值从普通 prompt 中拆出,使模型先学相对量,再学单位 1 的视觉/物理锚点", font=F_SUBTITLE, fill=(90, 100, 115))

    # Top input split
    y = 180
    boxes = [
        (90, y, 500, y + 130, "原始 prompt", "A cup with 1.0 L water\nA car moves at 2 m/s"),
        (650, y, 1060, y + 130, "场景 prompt", "杯子/小车/相机/背景\n保持稳定"),
        (1210, y, 1620, y + 130, "物理量字段", "quantity type + value + unit\nvolume: 1.0 L"),
    ]
    for x1, y1, x2, y2, h, b in boxes:
        round_rect(d, (x1, y1, x2, y2), 22, (255, 255, 255), outline=(202, 213, 226))
        d.text((x1 + 25, y1 + 20), h, font=F_HEAD, fill=(25, 40, 60))
        draw_wrapped(d, (x1 + 25, y1 + 60), b, F_BODY, (70, 80, 95), 30, 6)
    arrow(d, (500, y + 65), (650, y + 65))
    arrow(d, (1060, y + 65), (1210, y + 65))

    # Vocabulary and embedding
    y2 = 390
    round_rect(d, (90, y2, 690, y2 + 210), 24, (235, 248, 241), outline=(175, 210, 190))
    d.text((120, y2 + 25), "QuantityUnitBench / Token Schema", font=F_HEAD, fill=(20, 80, 55))
    draw_wrapped(d, (120, y2 + 70), "统计物理量类型、单位范围、分桶方式和可测代理信号。\n例:pH=0-14;volume=0.1-2.0L;speed=log bins。", F_BODY, (45, 65, 55), 42, 7)

    round_rect(d, (780, y2, 1560, y2 + 210), 24, (232, 241, 255), outline=(175, 195, 230))
    d.text((810, y2 + 25), "Quantity-specific Token Embedding", font=F_HEAD, fill=(35, 70, 125))
    draw_wrapped(d, (810, y2 + 70), "<VOL_0.5L>, <VOL_1.0L>, <SPD_2.0MPS>, <PH_07>\n借鉴 Textual Inversion:学习少量 token embedding,但含义是物理量数值/倍率。", F_BODY, (45, 60, 85), 56, 7)
    arrow(d, (690, y2 + 105), (780, y2 + 105))

    # Model core
    y3 = 690
    round_rect(d, (90, y3, 520, y3 + 240), 24, (255, 244, 229), outline=(225, 190, 145))
    d.text((120, y3 + 25), "视频基座模型", font=F_HEAD, fill=(110, 70, 20))
    draw_wrapped(d, (120, y3 + 70), "Wan / Hunyuan / LongCat\n冻结 backbone,训练 LoRA / adapter / token embedding。", F_BODY, (75, 65, 50), 32, 7)

    round_rect(d, (650, y3, 1030, y3 + 240), 24, (255, 255, 255), outline=(205, 215, 225))
    d.text((680, y3 + 25), "阶段一:相对量", font=F_HEAD, fill=(45, 55, 70))
    draw_wrapped(d, (680, y3 + 70), "同一场景生成:\n1x, 2x, 4x, 8x, 16x, 32x\nGPO/DPO/GRPO 学排序和倍率。", F_BODY, (55, 65, 80), 27, 7)

    round_rect(d, (1160, y3, 1600, y3 + 240), 24, (255, 255, 255), outline=(205, 215, 225))
    d.text((1190, y3 + 25), "阶段二:单位锚定", font=F_HEAD, fill=(45, 55, 70))
    draw_wrapped(d, (1190, y3 + 70), "给定 1 unit reference:\n刻度杯/标尺/弹簧/灯泡。\n学习 0.5x, 1x, 2x, 4x。", F_BODY, (55, 65, 80), 31, 7)

    arrow(d, (520, y3 + 120), (650, y3 + 120))
    arrow(d, (1030, y3 + 120), (1160, y3 + 120))
    arrow(d, (1170, y2 + 210), (920, y3), fill=(55, 95, 145))

    # Bottom reward/eval
    y4 = 1010
    round_rect(d, (90, y4, 790, y4 + 120), 22, (240, 244, 248), outline=(205, 215, 225))
    d.text((120, y4 + 22), "自动/半自动 reward", font=F_HEAD, fill=(45, 55, 70))
    draw_wrapped(d, (120, y4 + 60), "液面高度、像素长度、轨迹斜率、亮度、OCR、tracking、人工抽检", F_BODY, (65, 75, 88), 55, 6)

    round_rect(d, (920, y4, 1600, y4 + 120), 22, (240, 244, 248), outline=(205, 215, 225))
    d.text((950, y4 + 22), "Reference-conditioned editing", font=F_HEAD, fill=(45, 55, 70))
    draw_wrapped(d, (950, y4 + 60), "先固定 0 物理量/初始视频,再用数值 token 像 edit prompt 一样改变目标物理量。", F_BODY, (65, 75, 88), 52, 6)
    arrow(d, (790, y4 + 60), (920, y4 + 60))

    save_all(img, "quantity_token_pipeline_zh.png")


if __name__ == "__main__":
    build_literature_bridge()
    build_pipeline()