FangSen9000 commited on
Commit
de8597b
·
1 Parent(s): eaf4dff

A relatively perfect version

Browse files
Files changed (29) hide show
  1. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/analysis_report.txt +1 -1
  2. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_heatmap.pdf +0 -0
  3. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_heatmap.png +0 -0
  4. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_keyframes/keyframes_index.txt +1 -1
  5. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_weights.npy +0 -0
  6. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/debug_video_path.txt +0 -0
  7. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/feature_frame_mapping.json +0 -0
  8. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.json +0 -0
  9. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.pdf +0 -0
  10. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.png +2 -2
  11. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/gloss_to_frames.png +0 -0
  12. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/interactive_alignment.html +0 -0
  13. SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/translation.txt +0 -0
  14. SignX/detailed_prediction_20260101_133848/3381121/analysis_report.txt +43 -0
  15. SignX/detailed_prediction_20260101_133848/3381121/attention_heatmap.pdf +0 -0
  16. SignX/detailed_prediction_20260101_133848/3381121/attention_heatmap.png +3 -0
  17. SignX/detailed_prediction_20260101_133848/3381121/attention_keyframes/keyframes_index.txt +39 -0
  18. SignX/detailed_prediction_20260101_133848/3381121/attention_weights.npy +3 -0
  19. SignX/detailed_prediction_20260101_133848/3381121/debug_video_path.txt +4 -0
  20. SignX/detailed_prediction_20260101_133848/3381121/feature_frame_mapping.json +218 -0
  21. SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.json +86 -0
  22. SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.pdf +0 -0
  23. SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.png +3 -0
  24. SignX/detailed_prediction_20260101_133848/3381121/frame_alignment_short.pdf +0 -0
  25. SignX/detailed_prediction_20260101_133848/3381121/frame_alignment_short.png +3 -0
  26. SignX/detailed_prediction_20260101_133848/3381121/gloss_to_frames.png +3 -0
  27. SignX/detailed_prediction_20260101_133848/3381121/interactive_alignment.html +579 -0
  28. SignX/detailed_prediction_20260101_133848/3381121/translation.txt +3 -0
  29. SignX/eval/attention_analysis.py +150 -136
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/analysis_report.txt RENAMED
@@ -2,7 +2,7 @@
2
  Sign Language Recognition - Attention分析报告
3
  ================================================================================
4
 
5
- 生成时间: 2026-01-01 13:11:10
6
 
7
  翻译结果:
8
  --------------------------------------------------------------------------------
 
2
  Sign Language Recognition - Attention分析报告
3
  ================================================================================
4
 
5
+ 生成时间: 2026-01-01 13:24:03
6
 
7
  翻译结果:
8
  --------------------------------------------------------------------------------
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_heatmap.pdf RENAMED
Binary files a/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.pdf and b/SignX/detailed_prediction_20260101_132358/3381121/attention_heatmap.pdf differ
 
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_heatmap.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_keyframes/keyframes_index.txt RENAMED
@@ -1,7 +1,7 @@
1
  关键帧索引
2
  ============================================================
3
 
4
- 样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_131106/3381121
5
  视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4
6
  总关键帧数: 30
7
 
 
1
  关键帧索引
2
  ============================================================
3
 
4
+ 样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_132358/3381121
5
  视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4
6
  总关键帧数: 30
7
 
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/attention_weights.npy RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/debug_video_path.txt RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/feature_frame_mapping.json RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.json RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.pdf RENAMED
Binary files a/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.pdf and b/SignX/detailed_prediction_20260101_132358/3381121/frame_alignment.pdf differ
 
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/frame_alignment.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/gloss_to_frames.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/interactive_alignment.html RENAMED
File without changes
SignX/{detailed_prediction_20260101_131106 → detailed_prediction_20260101_132358}/3381121/translation.txt RENAMED
File without changes
SignX/detailed_prediction_20260101_133848/3381121/analysis_report.txt ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================================================================================
2
+ Sign Language Recognition - Attention分析报告
3
+ ================================================================================
4
+
5
+ 生成时间: 2026-01-01 13:38:55
6
+
7
+ 翻译结果:
8
+ --------------------------------------------------------------------------------
9
+ BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX
10
+
11
+ 视频信息:
12
+ --------------------------------------------------------------------------------
13
+ 总帧数: 35
14
+ 词数量: 8
15
+
16
+ Attention权重信息:
17
+ --------------------------------------------------------------------------------
18
+ 形状: (30, 35)
19
+ - 解码步数: 30
20
+
21
+ 词-帧对应详情:
22
+ ================================================================================
23
+ No. Word Frames Peak Attn Conf
24
+ --------------------------------------------------------------------------------
25
+ 1 BOX/ROOM 4-4 4 0.618 high
26
+ 2 IX 7-7 7 0.524 high
27
+ 3 NOT-YET 7-7 7 0.266 medium
28
+ 4 ARRIVE 8-10 8 0.308 medium
29
+ 5 IX 11-11 11 0.486 medium
30
+ 6 SHOULD 13-13 13 0.595 high
31
+ 7 CONTACT 13-13 13 0.179 low
32
+ 8 ns-fs-FEDEX 17-17 17 0.761 high
33
+
34
+ ================================================================================
35
+
36
+ 统计摘要:
37
+ --------------------------------------------------------------------------------
38
+ 平均attention权重: 0.467
39
+ 高置信度词: 4 (50.0%)
40
+ 中置信度词: 3 (37.5%)
41
+ 低置信度词: 1 (12.5%)
42
+
43
+ ================================================================================
SignX/detailed_prediction_20260101_133848/3381121/attention_heatmap.pdf ADDED
Binary file (34.7 kB). View file
 
SignX/detailed_prediction_20260101_133848/3381121/attention_heatmap.png ADDED

Git LFS Details

  • SHA256: 0ef8392c2b7438bd5eed3d032dd64084eab2c49f3c825752ebaccc6657d73ee2
  • Pointer size: 130 Bytes
  • Size of remote file: 90.1 kB
SignX/detailed_prediction_20260101_133848/3381121/attention_keyframes/keyframes_index.txt ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 关键帧索引
2
+ ============================================================
3
+
4
+ 样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_133848/3381121
5
+ 视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4
6
+ 总关键帧数: 30
7
+
8
+ 关键帧列表:
9
+ ------------------------------------------------------------
10
+ Gloss 0: keyframe_000_feat4_frame17_att0.618.jpg
11
+ Gloss 1: keyframe_001_feat7_frame29_att0.524.jpg
12
+ Gloss 2: keyframe_002_feat7_frame29_att0.266.jpg
13
+ Gloss 3: keyframe_003_feat8_frame32_att0.316.jpg
14
+ Gloss 4: keyframe_004_feat11_frame44_att0.486.jpg
15
+ Gloss 5: keyframe_005_feat13_frame52_att0.595.jpg
16
+ Gloss 6: keyframe_006_feat13_frame52_att0.179.jpg
17
+ Gloss 7: keyframe_007_feat17_frame67_att0.761.jpg
18
+ Gloss 8: keyframe_008_feat21_frame83_att0.176.jpg
19
+ Gloss 9: keyframe_009_feat22_frame87_att0.085.jpg
20
+ Gloss 10: keyframe_010_feat25_frame99_att0.222.jpg
21
+ Gloss 11: keyframe_011_feat28_frame110_att0.069.jpg
22
+ Gloss 12: keyframe_012_feat32_frame126_att0.146.jpg
23
+ Gloss 13: keyframe_013_feat32_frame126_att0.088.jpg
24
+ Gloss 14: keyframe_014_feat34_frame134_att0.117.jpg
25
+ Gloss 15: keyframe_015_feat32_frame126_att0.153.jpg
26
+ Gloss 16: keyframe_016_feat32_frame126_att0.090.jpg
27
+ Gloss 17: keyframe_017_feat34_frame134_att0.116.jpg
28
+ Gloss 18: keyframe_018_feat34_frame134_att0.119.jpg
29
+ Gloss 19: keyframe_019_feat34_frame134_att0.127.jpg
30
+ Gloss 20: keyframe_020_feat34_frame134_att0.128.jpg
31
+ Gloss 21: keyframe_021_feat32_frame126_att0.105.jpg
32
+ Gloss 22: keyframe_022_feat34_frame134_att0.139.jpg
33
+ Gloss 23: keyframe_023_feat34_frame134_att0.146.jpg
34
+ Gloss 24: keyframe_024_feat34_frame134_att0.149.jpg
35
+ Gloss 25: keyframe_025_feat34_frame134_att0.154.jpg
36
+ Gloss 26: keyframe_026_feat34_frame134_att0.157.jpg
37
+ Gloss 27: keyframe_027_feat34_frame134_att0.115.jpg
38
+ Gloss 28: keyframe_028_feat34_frame134_att0.161.jpg
39
+ Gloss 29: keyframe_029_feat34_frame134_att0.144.jpg
SignX/detailed_prediction_20260101_133848/3381121/attention_weights.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f75d778a2e7e7598b861f3b4b05e86ee83ce116f7594899cdac92ec25de5b2f2
3
+ size 4328
SignX/detailed_prediction_20260101_133848/3381121/debug_video_path.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ video_path = '/common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4'
2
+ video_path type = <class 'str'>
3
+ video_path is None: False
4
+ bool(video_path): True
SignX/detailed_prediction_20260101_133848/3381121/feature_frame_mapping.json ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "original_frame_count": 136,
3
+ "feature_count": 35,
4
+ "downsampling_ratio": 3.8857142857142857,
5
+ "fps": 30.0,
6
+ "mapping": [
7
+ {
8
+ "feature_index": 0,
9
+ "frame_start": 0,
10
+ "frame_end": 3,
11
+ "frame_count": 3
12
+ },
13
+ {
14
+ "feature_index": 1,
15
+ "frame_start": 3,
16
+ "frame_end": 7,
17
+ "frame_count": 4
18
+ },
19
+ {
20
+ "feature_index": 2,
21
+ "frame_start": 7,
22
+ "frame_end": 11,
23
+ "frame_count": 4
24
+ },
25
+ {
26
+ "feature_index": 3,
27
+ "frame_start": 11,
28
+ "frame_end": 15,
29
+ "frame_count": 4
30
+ },
31
+ {
32
+ "feature_index": 4,
33
+ "frame_start": 15,
34
+ "frame_end": 19,
35
+ "frame_count": 4
36
+ },
37
+ {
38
+ "feature_index": 5,
39
+ "frame_start": 19,
40
+ "frame_end": 23,
41
+ "frame_count": 4
42
+ },
43
+ {
44
+ "feature_index": 6,
45
+ "frame_start": 23,
46
+ "frame_end": 27,
47
+ "frame_count": 4
48
+ },
49
+ {
50
+ "feature_index": 7,
51
+ "frame_start": 27,
52
+ "frame_end": 31,
53
+ "frame_count": 4
54
+ },
55
+ {
56
+ "feature_index": 8,
57
+ "frame_start": 31,
58
+ "frame_end": 34,
59
+ "frame_count": 3
60
+ },
61
+ {
62
+ "feature_index": 9,
63
+ "frame_start": 34,
64
+ "frame_end": 38,
65
+ "frame_count": 4
66
+ },
67
+ {
68
+ "feature_index": 10,
69
+ "frame_start": 38,
70
+ "frame_end": 42,
71
+ "frame_count": 4
72
+ },
73
+ {
74
+ "feature_index": 11,
75
+ "frame_start": 42,
76
+ "frame_end": 46,
77
+ "frame_count": 4
78
+ },
79
+ {
80
+ "feature_index": 12,
81
+ "frame_start": 46,
82
+ "frame_end": 50,
83
+ "frame_count": 4
84
+ },
85
+ {
86
+ "feature_index": 13,
87
+ "frame_start": 50,
88
+ "frame_end": 54,
89
+ "frame_count": 4
90
+ },
91
+ {
92
+ "feature_index": 14,
93
+ "frame_start": 54,
94
+ "frame_end": 58,
95
+ "frame_count": 4
96
+ },
97
+ {
98
+ "feature_index": 15,
99
+ "frame_start": 58,
100
+ "frame_end": 62,
101
+ "frame_count": 4
102
+ },
103
+ {
104
+ "feature_index": 16,
105
+ "frame_start": 62,
106
+ "frame_end": 66,
107
+ "frame_count": 4
108
+ },
109
+ {
110
+ "feature_index": 17,
111
+ "frame_start": 66,
112
+ "frame_end": 69,
113
+ "frame_count": 3
114
+ },
115
+ {
116
+ "feature_index": 18,
117
+ "frame_start": 69,
118
+ "frame_end": 73,
119
+ "frame_count": 4
120
+ },
121
+ {
122
+ "feature_index": 19,
123
+ "frame_start": 73,
124
+ "frame_end": 77,
125
+ "frame_count": 4
126
+ },
127
+ {
128
+ "feature_index": 20,
129
+ "frame_start": 77,
130
+ "frame_end": 81,
131
+ "frame_count": 4
132
+ },
133
+ {
134
+ "feature_index": 21,
135
+ "frame_start": 81,
136
+ "frame_end": 85,
137
+ "frame_count": 4
138
+ },
139
+ {
140
+ "feature_index": 22,
141
+ "frame_start": 85,
142
+ "frame_end": 89,
143
+ "frame_count": 4
144
+ },
145
+ {
146
+ "feature_index": 23,
147
+ "frame_start": 89,
148
+ "frame_end": 93,
149
+ "frame_count": 4
150
+ },
151
+ {
152
+ "feature_index": 24,
153
+ "frame_start": 93,
154
+ "frame_end": 97,
155
+ "frame_count": 4
156
+ },
157
+ {
158
+ "feature_index": 25,
159
+ "frame_start": 97,
160
+ "frame_end": 101,
161
+ "frame_count": 4
162
+ },
163
+ {
164
+ "feature_index": 26,
165
+ "frame_start": 101,
166
+ "frame_end": 104,
167
+ "frame_count": 3
168
+ },
169
+ {
170
+ "feature_index": 27,
171
+ "frame_start": 104,
172
+ "frame_end": 108,
173
+ "frame_count": 4
174
+ },
175
+ {
176
+ "feature_index": 28,
177
+ "frame_start": 108,
178
+ "frame_end": 112,
179
+ "frame_count": 4
180
+ },
181
+ {
182
+ "feature_index": 29,
183
+ "frame_start": 112,
184
+ "frame_end": 116,
185
+ "frame_count": 4
186
+ },
187
+ {
188
+ "feature_index": 30,
189
+ "frame_start": 116,
190
+ "frame_end": 120,
191
+ "frame_count": 4
192
+ },
193
+ {
194
+ "feature_index": 31,
195
+ "frame_start": 120,
196
+ "frame_end": 124,
197
+ "frame_count": 4
198
+ },
199
+ {
200
+ "feature_index": 32,
201
+ "frame_start": 124,
202
+ "frame_end": 128,
203
+ "frame_count": 4
204
+ },
205
+ {
206
+ "feature_index": 33,
207
+ "frame_start": 128,
208
+ "frame_end": 132,
209
+ "frame_count": 4
210
+ },
211
+ {
212
+ "feature_index": 34,
213
+ "frame_start": 132,
214
+ "frame_end": 136,
215
+ "frame_count": 4
216
+ }
217
+ ]
218
+ }
SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "translation": "BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX",
3
+ "words": [
4
+ "BOX/ROOM",
5
+ "IX",
6
+ "NOT-YET",
7
+ "ARRIVE",
8
+ "IX",
9
+ "SHOULD",
10
+ "CONTACT",
11
+ "ns-fs-FEDEX"
12
+ ],
13
+ "total_video_frames": 35,
14
+ "frame_ranges": [
15
+ {
16
+ "word": "BOX/ROOM",
17
+ "start_frame": 4,
18
+ "end_frame": 4,
19
+ "peak_frame": 4,
20
+ "avg_attention": 0.6183844208717346,
21
+ "confidence": "high"
22
+ },
23
+ {
24
+ "word": "IX",
25
+ "start_frame": 7,
26
+ "end_frame": 7,
27
+ "peak_frame": 7,
28
+ "avg_attention": 0.5238878726959229,
29
+ "confidence": "high"
30
+ },
31
+ {
32
+ "word": "NOT-YET",
33
+ "start_frame": 7,
34
+ "end_frame": 7,
35
+ "peak_frame": 7,
36
+ "avg_attention": 0.26562702655792236,
37
+ "confidence": "medium"
38
+ },
39
+ {
40
+ "word": "ARRIVE",
41
+ "start_frame": 8,
42
+ "end_frame": 10,
43
+ "peak_frame": 8,
44
+ "avg_attention": 0.3079790771007538,
45
+ "confidence": "medium"
46
+ },
47
+ {
48
+ "word": "IX",
49
+ "start_frame": 11,
50
+ "end_frame": 11,
51
+ "peak_frame": 11,
52
+ "avg_attention": 0.48612749576568604,
53
+ "confidence": "medium"
54
+ },
55
+ {
56
+ "word": "SHOULD",
57
+ "start_frame": 13,
58
+ "end_frame": 13,
59
+ "peak_frame": 13,
60
+ "avg_attention": 0.5946471691131592,
61
+ "confidence": "high"
62
+ },
63
+ {
64
+ "word": "CONTACT",
65
+ "start_frame": 13,
66
+ "end_frame": 13,
67
+ "peak_frame": 13,
68
+ "avg_attention": 0.17889028787612915,
69
+ "confidence": "low"
70
+ },
71
+ {
72
+ "word": "ns-fs-FEDEX",
73
+ "start_frame": 17,
74
+ "end_frame": 17,
75
+ "peak_frame": 17,
76
+ "avg_attention": 0.7611479163169861,
77
+ "confidence": "high"
78
+ }
79
+ ],
80
+ "statistics": {
81
+ "avg_confidence": 0.46708640828728676,
82
+ "high_confidence_words": 4,
83
+ "medium_confidence_words": 3,
84
+ "low_confidence_words": 1
85
+ }
86
+ }
SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.pdf ADDED
Binary file (39.2 kB). View file
 
SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.png ADDED

Git LFS Details

  • SHA256: d8fef2577adb3d4ca68533f54e94ccb90bd51083f39683c76554b12c89f0a478
  • Pointer size: 131 Bytes
  • Size of remote file: 149 kB
SignX/detailed_prediction_20260101_133848/3381121/frame_alignment_short.pdf ADDED
Binary file (39 kB). View file
 
SignX/detailed_prediction_20260101_133848/3381121/frame_alignment_short.png ADDED

Git LFS Details

  • SHA256: 893c86a38055d620b27e989d07b6ce1caa8aed0cc0e816013e363058fad1fef6
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
SignX/detailed_prediction_20260101_133848/3381121/gloss_to_frames.png ADDED

Git LFS Details

  • SHA256: 1cf9fc261023740c5cae26682718d2d53aa31ec175a64443fa1c00136e72ba61
  • Pointer size: 132 Bytes
  • Size of remote file: 3.8 MB
SignX/detailed_prediction_20260101_133848/3381121/interactive_alignment.html ADDED
@@ -0,0 +1,579 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Interactive Word-Frame Alignment</title>
7
+ <style>
8
+ body {
9
+ font-family: 'Arial', sans-serif;
10
+ margin: 20px;
11
+ background-color: #f5f5f5;
12
+ }
13
+ .container {
14
+ max-width: 1800px;
15
+ margin: 0 auto;
16
+ background-color: white;
17
+ padding: 30px;
18
+ border-radius: 8px;
19
+ box-shadow: 0 2px 10px rgba(0,0,0,0.1);
20
+ }
21
+ h1 {
22
+ color: #333;
23
+ border-bottom: 3px solid #4CAF50;
24
+ padding-bottom: 10px;
25
+ margin-bottom: 20px;
26
+ }
27
+ .stats {
28
+ background-color: #E3F2FD;
29
+ padding: 15px;
30
+ border-radius: 5px;
31
+ margin-bottom: 20px;
32
+ border-left: 4px solid #2196F3;
33
+ font-size: 14px;
34
+ }
35
+ .controls {
36
+ background-color: #f9f9f9;
37
+ padding: 20px;
38
+ border-radius: 5px;
39
+ margin-bottom: 30px;
40
+ border: 1px solid #ddd;
41
+ }
42
+ .control-group {
43
+ margin-bottom: 15px;
44
+ }
45
+ label {
46
+ font-weight: bold;
47
+ display: inline-block;
48
+ width: 250px;
49
+ color: #555;
50
+ }
51
+ input[type="range"] {
52
+ width: 400px;
53
+ vertical-align: middle;
54
+ }
55
+ .value-display {
56
+ display: inline-block;
57
+ width: 80px;
58
+ font-family: monospace;
59
+ font-size: 14px;
60
+ color: #2196F3;
61
+ font-weight: bold;
62
+ }
63
+ .reset-btn {
64
+ margin-top: 15px;
65
+ padding: 10px 25px;
66
+ background-color: #2196F3;
67
+ color: white;
68
+ border: none;
69
+ border-radius: 5px;
70
+ cursor: pointer;
71
+ font-size: 14px;
72
+ font-weight: bold;
73
+ }
74
+ .reset-btn:hover {
75
+ background-color: #1976D2;
76
+ }
77
+ canvas {
78
+ border: 1px solid #999;
79
+ display: block;
80
+ margin: 20px auto;
81
+ background: white;
82
+ }
83
+ .legend {
84
+ margin-top: 20px;
85
+ padding: 15px;
86
+ background-color: #fff;
87
+ border: 1px solid #ddd;
88
+ border-radius: 5px;
89
+ }
90
+ .legend-item {
91
+ display: inline-block;
92
+ margin-right: 25px;
93
+ font-size: 13px;
94
+ margin-bottom: 10px;
95
+ }
96
+ .color-box {
97
+ display: inline-block;
98
+ width: 30px;
99
+ height: 15px;
100
+ margin-right: 8px;
101
+ vertical-align: middle;
102
+ border: 1px solid #666;
103
+ }
104
+ .info-panel {
105
+ margin-top: 20px;
106
+ padding: 15px;
107
+ background-color: #f9f9f9;
108
+ border-radius: 5px;
109
+ border: 1px solid #ddd;
110
+ }
111
+ .confidence {
112
+ display: inline-block;
113
+ padding: 3px 10px;
114
+ border-radius: 10px;
115
+ font-weight: bold;
116
+ font-size: 11px;
117
+ text-transform: uppercase;
118
+ }
119
+ .confidence.high {
120
+ background-color: #4CAF50;
121
+ color: white;
122
+ }
123
+ .confidence.medium {
124
+ background-color: #FF9800;
125
+ color: white;
126
+ }
127
+ .confidence.low {
128
+ background-color: #f44336;
129
+ color: white;
130
+ }
131
+ </style>
132
+ </head>
133
+ <body>
134
+ <div class="container">
135
+ <h1>🎯 Interactive Word-to-Frame Alignment Visualizer</h1>
136
+
137
+ <div class="stats">
138
+ <strong>Translation:</strong> BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX<br>
139
+ <strong>Total Words:</strong> 8 |
140
+ <strong>Total Features:</strong> 35
141
+ </div>
142
+
143
+ <div class="controls">
144
+ <h3>⚙️ Threshold Controls</h3>
145
+
146
+ <div class="control-group">
147
+ <label for="peak-threshold">Peak Threshold (% of max):</label>
148
+ <input type="range" id="peak-threshold" min="1" max="100" value="90" step="1">
149
+ <span class="value-display" id="peak-threshold-value">90%</span>
150
+ <br>
151
+ <small style="margin-left: 255px; color: #666;">
152
+ 帧的注意力权重 ≥ (峰值权重 × 阈值%) 时被认为是"显著帧"
153
+ </small>
154
+ </div>
155
+
156
+ <div class="control-group">
157
+ <label for="confidence-high">High Confidence (avg attn >):</label>
158
+ <input type="range" id="confidence-high" min="0" max="100" value="50" step="1">
159
+ <span class="value-display" id="confidence-high-value">0.50</span>
160
+ </div>
161
+
162
+ <div class="control-group">
163
+ <label for="confidence-medium">Medium Confidence (avg attn >):</label>
164
+ <input type="range" id="confidence-medium" min="0" max="100" value="20" step="1">
165
+ <span class="value-display" id="confidence-medium-value">0.20</span>
166
+ </div>
167
+
168
+ <button class="reset-btn" onclick="resetDefaults()">
169
+ Reset to Defaults
170
+ </button>
171
+ </div>
172
+
173
+ <div>
174
+ <h3>Word-to-Frame Alignment</h3>
175
+ <p style="color: #666; font-size: 13px;">
176
+ 每个词显示为彩色矩形,宽度表示该词对应的特征帧范围。★ = 峰值帧。矩形内部显示注意力权重波形。
177
+ </p>
178
+ <canvas id="alignment-canvas" width="1600" height="600"></canvas>
179
+
180
+ <h3 style="margin-top: 30px;">Timeline Progress Bar</h3>
181
+ <canvas id="timeline-canvas" width="1600" height="100"></canvas>
182
+
183
+ <div class="legend">
184
+ <strong>Legend:</strong><br><br>
185
+ <div class="legend-item">
186
+ <span class="confidence high">High</span>
187
+ <span class="confidence medium">Medium</span>
188
+ <span class="confidence low">Low</span>
189
+ Confidence Levels (opacity reflects confidence)
190
+ </div>
191
+ <div class="legend-item">
192
+ <span style="color: red; font-size: 20px;">★</span>
193
+ Peak Frame (highest attention)
194
+ </div>
195
+ <div class="legend-item">
196
+ <span style="color: blue;">━</span>
197
+ Attention Waveform (within word region)
198
+ </div>
199
+ </div>
200
+ </div>
201
+
202
+ <div class="info-panel">
203
+ <h3>Alignment Details</h3>
204
+ <div id="alignment-details"></div>
205
+ </div>
206
+ </div>
207
+
208
+ <script>
209
+ // Attention data from Python
210
+ const attentionData = [{"word": "BOX/ROOM", "word_idx": 0, "weights": [0.006351051852107048, 0.006571591831743717, 0.012744346633553505, 0.25818338990211487, 0.6183844208717346, 0.07160329818725586, 0.0038708881475031376, 0.0009234889294020832, 0.006989854387938976, 0.004734584596008062, 0.005883616860955954, 0.0007752194069325924, 0.00019075380987487733, 2.629558821354294e-06, 7.526499302912271e-06, 2.065691842290107e-05, 5.081619747215882e-05, 0.0004794567357748747, 0.0001349998638033867, 8.269475074484944e-05, 0.00010472737631062046, 7.984995318111032e-05, 6.447096529882401e-05, 7.145031850086525e-05, 0.00010799866140587255, 0.00015245474060066044, 0.00019921209604945034, 0.0001767162320902571, 0.00017511387704871595, 0.00020259163284208626, 0.00013320642756298184, 9.409035556018353e-05, 0.00012235736357979476, 0.00015512105892412364, 0.00017536635277792811]}, {"word": "IX", "word_idx": 1, "weights": [0.0011723862262442708, 0.0009910413064062595, 0.0016792321112006903, 0.009498031809926033, 0.014361615292727947, 0.04359763115644455, 0.280988484621048, 0.5238878726959229, 0.05194198712706566, 0.03270686790347099, 0.03140342980623245, 0.003325593890622258, 0.001596319954842329, 0.0011391377774998546, 0.0005484184948727489, 0.00033490045461803675, 7.97669927123934e-05, 0.0003001391014549881, 5.5829652410466224e-05, 7.975448170327581e-06, 8.45913564262446e-06, 1.2661466826102696e-05, 1.240926758327987e-05, 8.69539326231461e-06, 9.886168299999554e-06, 1.1390139661671128e-05, 1.0159355042560492e-05, 9.64598439168185e-06, 8.925362635636702e-06, 9.117472473008092e-06, 1.2588812751346268e-05, 2.6802983484230936e-05, 5.668022276950069e-05, 8.233459811890498e-05, 0.00010355122503824532]}, {"word": "NOT-YET", "word_idx": 2, "weights": [0.16965249180793762, 0.07323458045721054, 0.029197975993156433, 0.0025396100245416164, 0.002445423509925604, 0.009898832067847252, 0.037797823548316956, 0.26562702655792236, 0.009848427027463913, 0.00526211503893137, 0.004250594414770603, 0.0014572322834283113, 0.001674243831075728, 0.05451618880033493, 0.060803089290857315, 0.04630552604794502, 0.01521533913910389, 0.004090897738933563, 0.003519815392792225, 0.0038278333377093077, 0.0024895716924220324, 0.002131127519533038, 0.0033031043130904436, 0.0035419934429228306, 0.0020546577870845795, 0.0016667826566845179, 0.0013373601250350475, 0.0012249398278072476, 0.001324663171544671, 0.0019041926134377718, 0.004013519734144211, 0.019279679283499718, 0.04461098462343216, 0.053339678794145584, 0.05661269277334213]}, {"word": "ARRIVE", "word_idx": 3, "weights": [0.0002905388828366995, 0.0002083813596982509, 0.00032632541842758656, 0.0025478217285126448, 0.0073820799589157104, 0.014858342707157135, 0.018400374799966812, 0.021123293787240982, 0.3158378005027771, 0.25220221281051636, 0.30012035369873047, 0.010648821480572224, 0.001886643934994936, 6.4878404373303056e-06, 5.923872322455281e-06, 2.3099497411749326e-05, 0.0005105354939587414, 0.04699746519327164, 0.005902951583266258, 0.00029092541080899537, 0.00018096565327141434, 6.506430509034544e-05, 3.2437703339383006e-05, 2.104153281834442e-05, 7.040531727398047e-06, 7.098288733686786e-06, 7.855384865251835e-06, 6.147487965790788e-06, 5.554756626224844e-06, 7.759556865494233e-06, 6.213985670910915e-06, 1.072721897799056e-05, 1.9002200133400038e-05, 2.5421264581382275e-05, 2.727148421399761e-05]}, {"word": "IX", "word_idx": 4, "weights": [0.0003390431229490787, 0.00022571485897060484, 0.0002557964762672782, 0.0005381361697800457, 0.002120023826137185, 0.0273550096899271, 0.012844335287809372, 0.00290689617395401, 0.01703452318906784, 0.02637772634625435, 0.15619716048240662, 0.48612749576568604, 0.2603294849395752, 0.0005641445168294013, 0.00019721912394743413, 0.00033904434530995786, 0.0006775215733796358, 0.0013669012114405632, 0.0016405221540480852, 0.0007656495436094701, 0.0005228326190263033, 0.0003606425889302045, 0.00021389758330769837, 0.00013279783888719976, 3.7730329495389014e-05, 3.255438059568405e-05, 3.4443997719790787e-05, 3.628108970588073e-05, 3.273988113505766e-05, 3.9840597310103476e-05, 4.062296648044139e-05, 5.8705947594717145e-05, 7.590500899823382e-05, 9.174603474093601e-05, 8.684050408191979e-05]}, {"word": "SHOULD", "word_idx": 5, "weights": [0.00527340080589056, 0.004166516475379467, 0.003337869420647621, 0.0011889089364558458, 0.0007747402414679527, 0.01280419435352087, 0.03180841729044914, 0.04200495034456253, 0.002391757909208536, 0.004637685138732195, 0.006087929010391235, 0.01985923945903778, 0.060313232243061066, 0.5946471691131592, 0.15804460644721985, 0.029653724282979965, 0.0008350771386176348, 0.00013930512068327516, 0.00016234509530477226, 0.00027477910043671727, 0.0006075621349737048, 0.0018652487779036164, 0.0021796557120978832, 0.0014713223790749907, 0.0024460090789943933, 0.002028325106948614, 0.0012717237696051598, 0.001144407782703638, 0.0009023174061439931, 0.0005251378170214593, 0.0008574927924200892, 0.001382339047268033, 0.001502902596257627, 0.001733113662339747, 0.001676460960879922]}, {"word": "CONTACT", "word_idx": 6, "weights": [0.14272911846637726, 0.0573246069252491, 0.0188103336840868, 0.0006784269353374839, 0.00042378040961921215, 0.0014155198587104678, 0.0069302283227443695, 0.08298847824335098, 0.002187008038163185, 0.0017832987941801548, 0.0012008043704554439, 0.0009829651098698378, 0.0021144067868590355, 0.17889028787612915, 0.15413032472133636, 0.09035450220108032, 0.021829815581440926, 0.004844403825700283, 0.006283571477979422, 0.00830614659935236, 0.007968198508024216, 0.008506102487444878, 0.010532977990806103, 0.01149566750973463, 0.008719464763998985, 0.006225862540304661, 0.004270944744348526, 0.003964268136769533, 0.0038093950133770704, 0.004123717080801725, 0.006864133290946484, 0.021106082946062088, 0.03659150376915932, 0.041107941418886185, 0.04050571098923683]}, {"word": "ns-fs-FEDEX", "word_idx": 7, "weights": [7.23023695172742e-05, 5.213047916186042e-05, 4.6853372623445466e-05, 8.384212560486048e-05, 5.267366213956848e-05, 4.4198710384080186e-05, 6.236167973838747e-05, 0.0005651791580021381, 0.004614907316863537, 0.0062443651258945465, 0.00276308530010283, 0.0010768879437819123, 0.0007893505389802158, 0.0001608922757441178, 0.00028600034420378506, 0.0006088865338824689, 0.010051908902823925, 0.7611479163169861, 0.1628209799528122, 0.011173587292432785, 0.01768321916460991, 0.008066349662840366, 0.003297096583992243, 0.002270511817187071, 0.0019132717279717326, 0.0015967994695529342, 0.001093801110982895, 0.0005375861073844135, 0.00038413898437283933, 0.0001939320209203288, 7.028852996882051e-05, 4.9711332394508645e-05, 4.136270945309661e-05, 4.271505167707801e-05, 4.087587149115279e-05]}];
211
+ const numGlosses = 8;
212
+ const numFeatures = 35;
213
+
214
+ // Colors for different words (matching matplotlib tab20)
215
+ const colors = [
216
+ '#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
217
+ '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf',
218
+ '#aec7e8', '#ffbb78', '#98df8a', '#ff9896', '#c5b0d5',
219
+ '#c49c94', '#f7b6d2', '#c7c7c7', '#dbdb8d', '#9edae5'
220
+ ];
221
+
222
+ // Get controls
223
+ const peakThresholdSlider = document.getElementById('peak-threshold');
224
+ const peakThresholdValue = document.getElementById('peak-threshold-value');
225
+ const confidenceHighSlider = document.getElementById('confidence-high');
226
+ const confidenceHighValue = document.getElementById('confidence-high-value');
227
+ const confidenceMediumSlider = document.getElementById('confidence-medium');
228
+ const confidenceMediumValue = document.getElementById('confidence-medium-value');
229
+ const alignmentCanvas = document.getElementById('alignment-canvas');
230
+ const timelineCanvas = document.getElementById('timeline-canvas');
231
+ const alignmentCtx = alignmentCanvas.getContext('2d');
232
+ const timelineCtx = timelineCanvas.getContext('2d');
233
+
234
+ // Update displays when sliders change
235
+ peakThresholdSlider.oninput = function() {
236
+ peakThresholdValue.textContent = this.value + '%';
237
+ updateVisualization();
238
+ };
239
+
240
+ confidenceHighSlider.oninput = function() {
241
+ confidenceHighValue.textContent = (this.value / 100).toFixed(2);
242
+ updateVisualization();
243
+ };
244
+
245
+ confidenceMediumSlider.oninput = function() {
246
+ confidenceMediumValue.textContent = (this.value / 100).toFixed(2);
247
+ updateVisualization();
248
+ };
249
+
250
+ function resetDefaults() {
251
+ peakThresholdSlider.value = 90;
252
+ confidenceHighSlider.value = 50;
253
+ confidenceMediumSlider.value = 20;
254
+ peakThresholdValue.textContent = '90%';
255
+ confidenceHighValue.textContent = '0.50';
256
+ confidenceMediumValue.textContent = '0.20';
257
+ updateVisualization();
258
+ }
259
+
260
+ function calculateAlignment(weights, peakThreshold) {
261
+ // Find peak
262
+ let peakIdx = 0;
263
+ let peakWeight = weights[0];
264
+ for (let i = 1; i < weights.length; i++) {
265
+ if (weights[i] > peakWeight) {
266
+ peakWeight = weights[i];
267
+ peakIdx = i;
268
+ }
269
+ }
270
+
271
+ // Find significant frames
272
+ const threshold = peakWeight * (peakThreshold / 100);
273
+ let startIdx = peakIdx;
274
+ let endIdx = peakIdx;
275
+ let sumWeight = 0;
276
+ let count = 0;
277
+
278
+ for (let i = 0; i < weights.length; i++) {
279
+ if (weights[i] >= threshold) {
280
+ if (i < startIdx) startIdx = i;
281
+ if (i > endIdx) endIdx = i;
282
+ sumWeight += weights[i];
283
+ count++;
284
+ }
285
+ }
286
+
287
+ const avgWeight = count > 0 ? sumWeight / count : peakWeight;
288
+
289
+ return {
290
+ startIdx: startIdx,
291
+ endIdx: endIdx,
292
+ peakIdx: peakIdx,
293
+ peakWeight: peakWeight,
294
+ avgWeight: avgWeight,
295
+ threshold: threshold
296
+ };
297
+ }
298
+
299
+ function getConfidenceLevel(avgWeight, highThreshold, mediumThreshold) {
300
+ if (avgWeight > highThreshold) return 'high';
301
+ if (avgWeight > mediumThreshold) return 'medium';
302
+ return 'low';
303
+ }
304
+
305
+ function drawAlignmentChart() {
306
+ const peakThreshold = parseInt(peakThresholdSlider.value);
307
+ const highThreshold = parseInt(confidenceHighSlider.value) / 100;
308
+ const mediumThreshold = parseInt(confidenceMediumSlider.value) / 100;
309
+
310
+ // Canvas dimensions
311
+ const width = alignmentCanvas.width;
312
+ const height = alignmentCanvas.height;
313
+ const leftMargin = 180;
314
+ const rightMargin = 50;
315
+ const topMargin = 60;
316
+ const bottomMargin = 80;
317
+
318
+ const plotWidth = width - leftMargin - rightMargin;
319
+ const plotHeight = height - topMargin - bottomMargin;
320
+
321
+ const rowHeight = plotHeight / numGlosses;
322
+ const featureWidth = plotWidth / numFeatures;
323
+
324
+ // Clear canvas
325
+ alignmentCtx.clearRect(0, 0, width, height);
326
+
327
+ // Draw title
328
+ alignmentCtx.fillStyle = '#333';
329
+ alignmentCtx.font = 'bold 18px Arial';
330
+ alignmentCtx.textAlign = 'center';
331
+ alignmentCtx.fillText('Word-to-Frame Alignment', width / 2, 30);
332
+ alignmentCtx.font = '13px Arial';
333
+ alignmentCtx.fillText('(based on attention peaks, ★ = peak frame)', width / 2, 48);
334
+
335
+ // Calculate alignments
336
+ const alignments = [];
337
+ for (let wordIdx = 0; wordIdx < numGlosses; wordIdx++) {
338
+ const data = attentionData[wordIdx];
339
+ const alignment = calculateAlignment(data.weights, peakThreshold);
340
+ alignment.word = data.word;
341
+ alignment.wordIdx = wordIdx;
342
+ alignment.weights = data.weights;
343
+ alignments.push(alignment);
344
+ }
345
+
346
+ // Draw grid
347
+ alignmentCtx.strokeStyle = '#e0e0e0';
348
+ alignmentCtx.lineWidth = 0.5;
349
+ for (let i = 0; i <= numFeatures; i++) {
350
+ const x = leftMargin + i * featureWidth;
351
+ alignmentCtx.beginPath();
352
+ alignmentCtx.moveTo(x, topMargin);
353
+ alignmentCtx.lineTo(x, topMargin + plotHeight);
354
+ alignmentCtx.stroke();
355
+ }
356
+
357
+ // Draw word regions
358
+ for (let wordIdx = 0; wordIdx < numGlosses; wordIdx++) {
359
+ const alignment = alignments[wordIdx];
360
+ const confidence = getConfidenceLevel(alignment.avgWeight, highThreshold, mediumThreshold);
361
+ const y = topMargin + wordIdx * rowHeight;
362
+
363
+ // Alpha based on confidence
364
+ const alpha = confidence === 'high' ? 0.9 : confidence === 'medium' ? 0.7 : 0.5;
365
+
366
+ // Draw rectangle for word region
367
+ const startX = leftMargin + alignment.startIdx * featureWidth;
368
+ const rectWidth = (alignment.endIdx - alignment.startIdx + 1) * featureWidth;
369
+
370
+ alignmentCtx.fillStyle = colors[wordIdx % 20];
371
+ alignmentCtx.globalAlpha = alpha;
372
+ alignmentCtx.fillRect(startX, y, rectWidth, rowHeight * 0.8);
373
+ alignmentCtx.globalAlpha = 1.0;
374
+
375
+ // Draw border
376
+ alignmentCtx.strokeStyle = '#000';
377
+ alignmentCtx.lineWidth = 2;
378
+ alignmentCtx.strokeRect(startX, y, rectWidth, rowHeight * 0.8);
379
+
380
+ // Draw attention waveform inside rectangle
381
+ alignmentCtx.strokeStyle = 'rgba(0, 0, 255, 0.8)';
382
+ alignmentCtx.lineWidth = 1.5;
383
+ alignmentCtx.beginPath();
384
+ for (let i = alignment.startIdx; i <= alignment.endIdx; i++) {
385
+ const x = leftMargin + i * featureWidth + featureWidth / 2;
386
+ const weight = alignment.weights[i];
387
+ const maxWeight = alignment.peakWeight;
388
+ const normalizedWeight = weight / (maxWeight * 1.2); // Scale for visibility
389
+ const waveY = y + rowHeight * 0.8 - (normalizedWeight * rowHeight * 0.6);
390
+
391
+ if (i === alignment.startIdx) {
392
+ alignmentCtx.moveTo(x, waveY);
393
+ } else {
394
+ alignmentCtx.lineTo(x, waveY);
395
+ }
396
+ }
397
+ alignmentCtx.stroke();
398
+
399
+ // Draw word label
400
+ const labelX = startX + rectWidth / 2;
401
+ const labelY = y + rowHeight * 0.4;
402
+
403
+ alignmentCtx.fillStyle = 'rgba(0, 0, 0, 0.7)';
404
+ alignmentCtx.fillRect(labelX - 60, labelY - 12, 120, 24);
405
+ alignmentCtx.fillStyle = '#fff';
406
+ alignmentCtx.font = 'bold 13px Arial';
407
+ alignmentCtx.textAlign = 'center';
408
+ alignmentCtx.textBaseline = 'middle';
409
+ alignmentCtx.fillText(alignment.word, labelX, labelY);
410
+
411
+ // Mark peak frame with star
412
+ const peakX = leftMargin + alignment.peakIdx * featureWidth + featureWidth / 2;
413
+ const peakY = y + rowHeight * 0.4;
414
+
415
+ // Draw star
416
+ alignmentCtx.fillStyle = '#ff0000';
417
+ alignmentCtx.strokeStyle = '#ffff00';
418
+ alignmentCtx.lineWidth = 1.5;
419
+ alignmentCtx.font = '20px Arial';
420
+ alignmentCtx.textAlign = 'center';
421
+ alignmentCtx.strokeText('★', peakX, peakY);
422
+ alignmentCtx.fillText('★', peakX, peakY);
423
+
424
+ // Y-axis label (word names)
425
+ alignmentCtx.fillStyle = '#333';
426
+ alignmentCtx.font = '12px Arial';
427
+ alignmentCtx.textAlign = 'right';
428
+ alignmentCtx.textBaseline = 'middle';
429
+ alignmentCtx.fillText(alignment.word, leftMargin - 10, y + rowHeight * 0.4);
430
+ }
431
+
432
+ // Draw horizontal grid lines
433
+ alignmentCtx.strokeStyle = '#ccc';
434
+ alignmentCtx.lineWidth = 0.5;
435
+ for (let i = 0; i <= numGlosses; i++) {
436
+ const y = topMargin + i * rowHeight;
437
+ alignmentCtx.beginPath();
438
+ alignmentCtx.moveTo(leftMargin, y);
439
+ alignmentCtx.lineTo(leftMargin + plotWidth, y);
440
+ alignmentCtx.stroke();
441
+ }
442
+
443
+ // Draw axes
444
+ alignmentCtx.strokeStyle = '#000';
445
+ alignmentCtx.lineWidth = 2;
446
+ alignmentCtx.strokeRect(leftMargin, topMargin, plotWidth, plotHeight);
447
+
448
+ // X-axis labels (frame indices)
449
+ alignmentCtx.fillStyle = '#000';
450
+ alignmentCtx.font = '11px Arial';
451
+ alignmentCtx.textAlign = 'center';
452
+ alignmentCtx.textBaseline = 'top';
453
+ for (let i = 0; i < numFeatures; i++) {
454
+ const x = leftMargin + i * featureWidth + featureWidth / 2;
455
+ alignmentCtx.fillText(i.toString(), x, topMargin + plotHeight + 10);
456
+ }
457
+
458
+ // Axis titles
459
+ alignmentCtx.fillStyle = '#333';
460
+ alignmentCtx.font = 'bold 14px Arial';
461
+ alignmentCtx.textAlign = 'center';
462
+ alignmentCtx.fillText('Feature Frame Index', leftMargin + plotWidth / 2, height - 20);
463
+
464
+ alignmentCtx.save();
465
+ alignmentCtx.translate(30, topMargin + plotHeight / 2);
466
+ alignmentCtx.rotate(-Math.PI / 2);
467
+ alignmentCtx.fillText('Generated Word', 0, 0);
468
+ alignmentCtx.restore();
469
+
470
+ return alignments;
471
+ }
472
+
473
+ function drawTimeline(alignments) {
474
+ const highThreshold = parseInt(confidenceHighSlider.value) / 100;
475
+ const mediumThreshold = parseInt(confidenceMediumSlider.value) / 100;
476
+
477
+ const width = timelineCanvas.width;
478
+ const height = timelineCanvas.height;
479
+ const leftMargin = 180;
480
+ const rightMargin = 50;
481
+ const plotWidth = width - leftMargin - rightMargin;
482
+ const featureWidth = plotWidth / numFeatures;
483
+
484
+ // Clear canvas
485
+ timelineCtx.clearRect(0, 0, width, height);
486
+
487
+ // Background bar
488
+ timelineCtx.fillStyle = '#ddd';
489
+ timelineCtx.fillRect(leftMargin, 30, plotWidth, 40);
490
+ timelineCtx.strokeStyle = '#000';
491
+ timelineCtx.lineWidth = 2;
492
+ timelineCtx.strokeRect(leftMargin, 30, plotWidth, 40);
493
+
494
+ // Draw word regions on timeline
495
+ for (let wordIdx = 0; wordIdx < alignments.length; wordIdx++) {
496
+ const alignment = alignments[wordIdx];
497
+ const confidence = getConfidenceLevel(alignment.avgWeight, highThreshold, mediumThreshold);
498
+ const alpha = confidence === 'high' ? 0.9 : confidence === 'medium' ? 0.7 : 0.5;
499
+
500
+ const startX = leftMargin + alignment.startIdx * featureWidth;
501
+ const rectWidth = (alignment.endIdx - alignment.startIdx + 1) * featureWidth;
502
+
503
+ timelineCtx.fillStyle = colors[wordIdx % 20];
504
+ timelineCtx.globalAlpha = alpha;
505
+ timelineCtx.fillRect(startX, 30, rectWidth, 40);
506
+ timelineCtx.globalAlpha = 1.0;
507
+ timelineCtx.strokeStyle = '#000';
508
+ timelineCtx.lineWidth = 0.5;
509
+ timelineCtx.strokeRect(startX, 30, rectWidth, 40);
510
+ }
511
+
512
+ // Title
513
+ timelineCtx.fillStyle = '#333';
514
+ timelineCtx.font = 'bold 13px Arial';
515
+ timelineCtx.textAlign = 'left';
516
+ timelineCtx.fillText('Timeline Progress Bar', leftMargin, 20);
517
+ }
518
+
519
+ function updateDetailsPanel(alignments, highThreshold, mediumThreshold) {
520
+ const panel = document.getElementById('alignment-details');
521
+ let html = '<table style="width: 100%; border-collapse: collapse;">';
522
+ html += '<tr style="background: #f0f0f0; font-weight: bold;">';
523
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Word</th>';
524
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Feature Range</th>';
525
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Peak</th>';
526
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Span</th>';
527
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Avg Attention</th>';
528
+ html += '<th style="padding: 8px; border: 1px solid #ddd;">Confidence</th>';
529
+ html += '</tr>';
530
+
531
+ for (const align of alignments) {
532
+ const confidence = getConfidenceLevel(align.avgWeight, highThreshold, mediumThreshold);
533
+ const span = align.endIdx - align.startIdx + 1;
534
+
535
+ html += '<tr>';
536
+ html += `<td style="padding: 8px; border: 1px solid #ddd;"><strong>${align.word}</strong></td>`;
537
+ html += `<td style="padding: 8px; border: 1px solid #ddd;">${align.startIdx} → ${align.endIdx}</td>`;
538
+ html += `<td style="padding: 8px; border: 1px solid #ddd;">${align.peakIdx}</td>`;
539
+ html += `<td style="padding: 8px; border: 1px solid #ddd;">${span}</td>`;
540
+ html += `<td style="padding: 8px; border: 1px solid #ddd;">${align.avgWeight.toFixed(4)}</td>`;
541
+ html += `<td style="padding: 8px; border: 1px solid #ddd;"><span class="confidence ${confidence}">${confidence}</span></td>`;
542
+ html += '</tr>';
543
+ }
544
+
545
+ html += '</table>';
546
+ panel.innerHTML = html;
547
+ }
548
+
549
+ function updateVisualization() {
550
+ const alignments = drawAlignmentChart();
551
+ drawTimeline(alignments);
552
+ const highThreshold = parseInt(confidenceHighSlider.value) / 100;
553
+ const mediumThreshold = parseInt(confidenceMediumSlider.value) / 100;
554
+ updateDetailsPanel(alignments, highThreshold, mediumThreshold);
555
+ }
556
+
557
+ // Event listeners for sliders
558
+ peakSlider.addEventListener('input', function() {
559
+ peakValue.textContent = peakSlider.value + '%';
560
+ updateVisualization();
561
+ });
562
+
563
+ confidenceHighSlider.addEventListener('input', function() {
564
+ const val = parseInt(confidenceHighSlider.value) / 100;
565
+ confidenceHighValue.textContent = val.toFixed(2);
566
+ updateVisualization();
567
+ });
568
+
569
+ confidenceMediumSlider.addEventListener('input', function() {
570
+ const val = parseInt(confidenceMediumSlider.value) / 100;
571
+ confidenceMediumValue.textContent = val.toFixed(2);
572
+ updateVisualization();
573
+ });
574
+
575
+ // Initial visualization
576
+ updateVisualization();
577
+ </script>
578
+ </body>
579
+ </html>
SignX/detailed_prediction_20260101_133848/3381121/translation.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ With BPE: BOX/ROOM I@@ X NOT-YET ARRIVE I@@ X SHOULD CONT@@ ACT ns-fs-@@ F@@ E@@ DE@@ X
2
+ Clean: BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX
3
+ Ground Truth: BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX
SignX/eval/attention_analysis.py CHANGED
@@ -256,9 +256,11 @@ class AttentionAnalyzer:
256
  print(" 跳过对齐图: matplotlib未安装")
257
  return
258
 
 
 
259
  # Try to load feature-to-frame mapping
260
  feature_mapping = None
261
- output_dir = Path(output_path).parent
262
  mapping_file = output_dir / "feature_frame_mapping.json"
263
  if mapping_file.exists():
264
  try:
@@ -267,152 +269,164 @@ class AttentionAnalyzer:
267
  except Exception as e:
268
  print(f" Warning: Failed to load feature mapping: {e}")
269
 
270
- # Adjust layout based on whether we have feature mapping
271
- if feature_mapping:
272
- fig = plt.figure(figsize=(18, 10))
273
- gs = GridSpec(4, 1, height_ratios=[4, 1, 1, 0.5], hspace=0.4)
274
  else:
275
- fig = plt.figure(figsize=(18, 8))
276
- gs = GridSpec(3, 1, height_ratios=[4, 1, 0.5], hspace=0.4)
277
-
278
- # === 上图: 词-帧对齐 ===
279
- ax1 = fig.add_subplot(gs[0])
280
-
281
- colors = plt.cm.tab20(np.linspace(0, 1, max(len(self.words), 20)))
282
-
283
- for i, word_info in enumerate(self.word_frame_ranges):
284
- start = word_info['start_frame']
285
- end = word_info['end_frame']
286
- word = word_info['word']
287
- confidence = word_info['confidence']
288
-
289
- # 根据置信度设置透明度
290
- alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
291
-
292
- # 绘制矩形
293
- rect = patches.Rectangle(
294
- (start, i), end - start + 1, 0.8,
295
- linewidth=2, edgecolor='black',
296
- facecolor=colors[i % 20], alpha=alpha
297
- )
298
- ax1.add_patch(rect)
299
-
300
- # 添加词标签
301
- ax1.text(start + (end - start) / 2, i + 0.4, word,
302
- ha='center', va='center', fontsize=11,
303
- fontweight='bold', color='white',
304
- bbox=dict(boxstyle='round,pad=0.3', facecolor='black', alpha=0.5))
305
-
306
- # 标记峰值帧
307
- peak = word_info['peak_frame']
308
- ax1.plot(peak, i + 0.4, 'r*', markersize=15, markeredgecolor='yellow',
309
- markeredgewidth=1.5)
310
-
311
- ax1.set_xlim(-2, self.video_frames + 2)
312
- ax1.set_ylim(-0.5, len(self.words))
313
- # Remove redundant label (timeline info shown below)
314
- ax1.set_xlabel('')
315
- ax1.set_ylabel('Generated Word', fontsize=13, fontweight='bold')
316
- ax1.set_title('Word-to-Frame Alignment\n(based on attention peaks, ★ = peak frame)',
317
- fontsize=15, pad=15, fontweight='bold')
318
- ax1.grid(True, alpha=0.3, axis='x', linestyle='--')
319
- ax1.set_yticks(range(len(self.words)))
320
- ax1.set_yticklabels([w['word'] for w in self.word_frame_ranges], fontsize=10)
321
- ax1_label_pos = ax1.yaxis.label.get_position()
322
-
323
- # === 中图1: SMKD特征帧时间线进度条 ===
324
- ax2 = fig.add_subplot(gs[1])
325
-
326
- # 背景
327
- ax2.barh(0, self.video_frames, height=0.6, color='lightgray',
328
- edgecolor='black', linewidth=2)
329
-
330
- # 每个词的区域
331
- for i, word_info in enumerate(self.word_frame_ranges):
332
- start = word_info['start_frame']
333
- end = word_info['end_frame']
334
- confidence = word_info['confidence']
335
- alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
336
-
337
- ax2.barh(0, end - start + 1, left=start, height=0.6,
338
- color=colors[i % 20], alpha=alpha, edgecolor='black', linewidth=0.5)
339
-
340
- ax2.set_xlim(-2, self.video_frames + 2)
341
- ax2.set_ylim(-0.4, 0.4)
342
- ax2.set_xlabel('')
343
- ax2.set_yticks([])
344
- ax2.set_title('Latent Feature Timeline', fontsize=13, fontweight='bold')
345
- ax2.grid(True, alpha=0.3, axis='x', linestyle='--')
346
-
347
- # === 中图2: 原始视频帧时间线进度条 (如果有feature mapping) ===
348
- timeline_axes = [ax2]
349
-
350
  if feature_mapping:
351
- ax3 = fig.add_subplot(gs[2])
352
-
353
- original_frame_count = feature_mapping['original_frame_count']
 
 
 
 
 
 
 
 
 
 
 
354
 
355
- # 背景
356
- ax3.barh(0, original_frame_count, height=0.6, color='lightgray',
357
- edgecolor='black', linewidth=2)
358
 
359
- # 每个词对应的原始帧区域
360
  for i, word_info in enumerate(self.word_frame_ranges):
361
- feat_start = word_info['start_frame']
362
- feat_end = word_info['end_frame']
 
363
  confidence = word_info['confidence']
364
  alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
365
 
366
- # 从feature mapping中找到对应的原始帧范围
367
- # 使用特征帧的起始和结束索引来查找原始帧范围
368
- mapping_list = feature_mapping['mapping']
369
- if feat_start < len(mapping_list) and feat_end < len(mapping_list):
370
- orig_start = mapping_list[feat_start]['frame_start']
371
- orig_end = mapping_list[feat_end]['frame_end']
372
-
373
- ax3.barh(0, orig_end - orig_start, left=orig_start, height=0.6,
374
- color=colors[i % 20], alpha=alpha, edgecolor='black', linewidth=0.5)
375
-
376
- ax3.set_xlim(-2, original_frame_count + 2)
377
- ax3.set_ylim(-0.4, 0.4)
378
- ax3.set_xlabel('')
379
- ax3.set_yticks([])
380
- ax3.set_title(f'Original Video Timeline ({original_frame_count} frames, '
381
- f'{feature_mapping["downsampling_ratio"]:.2f}x downsampling)',
382
- fontsize=13, fontweight='bold')
383
- ax3.grid(True, alpha=0.3, axis='x', linestyle='--')
384
-
385
- legend_row = 3
386
- timeline_axes.append(ax3)
387
- else:
388
- legend_row = 2
389
-
390
- # === 下图: 置信度图例 ===
391
- ax_legend = fig.add_subplot(gs[legend_row])
392
- ax_legend.axis('off')
393
-
394
- legend_text = "Confidence: ■ High (avg attn > 0.5) ■ Medium (0.2-0.5) ■ Low (< 0.2)"
395
- ax_legend.text(0.5, 0.5, legend_text, ha='center', va='center',
396
- fontsize=11, transform=ax_legend.transAxes)
397
-
398
- plt.tight_layout()
399
- fig.canvas.draw()
 
 
 
400
 
401
- # Draw shared Timeline label aligned with Generated Word label (after layout)
402
- label_disp = ax1.transAxes.transform(ax1_label_pos)
403
- label_fig = fig.transFigure.inverted().transform(label_disp)
404
- timeline_bounds = [ax.get_position() for ax in timeline_axes]
405
- timeline_center = 0.5 * (min(pos.y0 for pos in timeline_bounds) + max(pos.y1 for pos in timeline_bounds))
406
- fig.text(label_fig[0], timeline_center, 'Timeline', rotation='vertical',
407
- ha='center', va='center', fontsize=12, fontweight='bold')
 
408
 
409
- plt.savefig(output_path, dpi=150, bbox_inches='tight')
410
- # Save PDF copy for high-res needs
411
- pdf_path = Path(output_path).with_suffix('.pdf')
412
- plt.savefig(str(pdf_path), format='pdf', bbox_inches='tight')
413
- plt.close()
414
 
415
- print(f" ✓ {output_path.name} (PDF copy saved)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
 
417
  def save_alignment_data(self, output_path):
418
  """保存帧对齐数据为JSON"""
 
256
  print(" 跳过对齐图: matplotlib未安装")
257
  return
258
 
259
+ output_path = Path(output_path)
260
+
261
  # Try to load feature-to-frame mapping
262
  feature_mapping = None
263
+ output_dir = output_path.parent
264
  mapping_file = output_dir / "feature_frame_mapping.json"
265
  if mapping_file.exists():
266
  try:
 
269
  except Exception as e:
270
  print(f" Warning: Failed to load feature mapping: {e}")
271
 
272
+ if self.word_frame_ranges:
273
+ max_feat_end = max(w['end_frame'] for w in self.word_frame_ranges)
 
 
274
  else:
275
+ max_feat_end = self.video_frames - 1
276
+ latent_full_limit = self.video_frames + 2
277
+ latent_short_limit = max(min(latent_full_limit, max_feat_end + 2), 5)
278
+
279
+ original_frame_count = None
280
+ mapping_list = None
281
+ orig_full_limit = None
282
+ orig_short_limit = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  if feature_mapping:
284
+ original_frame_count = feature_mapping.get('original_frame_count', self.video_frames)
285
+ mapping_list = feature_mapping.get('mapping', [])
286
+ orig_full_limit = original_frame_count + 2
287
+ if mapping_list:
288
+ idx = min(max_feat_end, len(mapping_list) - 1)
289
+ orig_short_limit = mapping_list[idx]['frame_end'] + 2
290
+
291
+ def render_alignment(out_path, latent_xlim_end, orig_xlim_end=None):
292
+ if feature_mapping:
293
+ fig = plt.figure(figsize=(18, 10))
294
+ gs = GridSpec(4, 1, height_ratios=[4, 1, 1, 0.5], hspace=0.4)
295
+ else:
296
+ fig = plt.figure(figsize=(18, 8))
297
+ gs = GridSpec(3, 1, height_ratios=[4, 1, 0.5], hspace=0.4)
298
 
299
+ # === 上图: 词-帧对齐 ===
300
+ ax1 = fig.add_subplot(gs[0])
301
+ colors = plt.cm.tab20(np.linspace(0, 1, max(len(self.words), 20)))
302
 
 
303
  for i, word_info in enumerate(self.word_frame_ranges):
304
+ start = word_info['start_frame']
305
+ end = word_info['end_frame']
306
+ word = word_info['word']
307
  confidence = word_info['confidence']
308
  alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
309
 
310
+ rect = patches.Rectangle(
311
+ (start, i), end - start + 1, 0.8,
312
+ linewidth=2, edgecolor='black',
313
+ facecolor=colors[i % 20], alpha=alpha
314
+ )
315
+ ax1.add_patch(rect)
316
+
317
+ ax1.text(start + (end - start) / 2, i + 0.4, word,
318
+ ha='center', va='center', fontsize=11,
319
+ fontweight='bold', color='white',
320
+ bbox=dict(boxstyle='round,pad=0.3', facecolor='black', alpha=0.5))
321
+
322
+ peak = word_info['peak_frame']
323
+ ax1.plot(peak, i + 0.4, 'r*', markersize=15, markeredgecolor='yellow',
324
+ markeredgewidth=1.5)
325
+
326
+ ax1.set_xlim(-2, latent_xlim_end)
327
+ ax1.set_ylim(-0.5, len(self.words))
328
+ ax1.set_xlabel('')
329
+ ax1.set_ylabel('')
330
+ ax1.set_title('Word-to-Frame Alignment\n(based on attention peaks, ★ = peak frame)',
331
+ fontsize=15, pad=15, fontweight='bold')
332
+ ax1.grid(True, alpha=0.3, axis='x', linestyle='--')
333
+ ax1.set_yticks(range(len(self.words)))
334
+ ax1.set_yticklabels([w['word'] for w in self.word_frame_ranges], fontsize=10)
335
+
336
+ # === 中图1: Latent timeline ===
337
+ ax2 = fig.add_subplot(gs[1])
338
+ ax2.barh(0, self.video_frames, height=0.6, color='lightgray',
339
+ edgecolor='black', linewidth=2)
340
+ for i, word_info in enumerate(self.word_frame_ranges):
341
+ start = word_info['start_frame']
342
+ end = word_info['end_frame']
343
+ confidence = word_info['confidence']
344
+ alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
345
+ ax2.barh(0, end - start + 1, left=start, height=0.6,
346
+ color=colors[i % 20], alpha=alpha, edgecolor='black', linewidth=0.5)
347
 
348
+ ax2.set_xlim(-2, latent_xlim_end)
349
+ ax2.set_ylim(-0.4, 0.4)
350
+ ax2.set_xlabel('')
351
+ ax2.set_yticks([0])
352
+ ax2.set_yticklabels(['Latent Space'], fontsize=11, fontweight='bold')
353
+ ax2.tick_params(axis='y', length=0)
354
+ ax2.set_title('Latent Feature Timeline', fontsize=13, fontweight='bold')
355
+ ax2.grid(True, alpha=0.3, axis='x', linestyle='--')
356
 
357
+ timeline_axes = [ax2]
 
 
 
 
358
 
359
+ if feature_mapping:
360
+ ax3 = fig.add_subplot(gs[2])
361
+ ax3.barh(0, original_frame_count, height=0.6, color='lightgray',
362
+ edgecolor='black', linewidth=2)
363
+
364
+ for i, word_info in enumerate(self.word_frame_ranges):
365
+ feat_start = word_info['start_frame']
366
+ feat_end = word_info['end_frame']
367
+ confidence = word_info['confidence']
368
+ alpha = 0.9 if confidence == 'high' else 0.7 if confidence == 'medium' else 0.5
369
+ if mapping_list and feat_start < len(mapping_list) and feat_end < len(mapping_list):
370
+ orig_start = mapping_list[feat_start]['frame_start']
371
+ orig_end = mapping_list[feat_end]['frame_end']
372
+ ax3.barh(0, orig_end - orig_start, left=orig_start, height=0.6,
373
+ color=colors[i % 20], alpha=alpha, edgecolor='black', linewidth=0.5)
374
+
375
+ ax3_xlim = orig_xlim_end if orig_xlim_end is not None else original_frame_count + 2
376
+ ax3.set_xlim(-2, ax3_xlim)
377
+ ax3.set_ylim(-0.4, 0.4)
378
+ ax3.set_xlabel('')
379
+ ax3.set_yticks([0])
380
+ ax3.set_yticklabels(['Pixel Space'], fontsize=11, fontweight='bold')
381
+ ax3.tick_params(axis='y', length=0)
382
+ ax3.set_title(f'Original Video Timeline ({original_frame_count} frames, '
383
+ f'{feature_mapping["downsampling_ratio"]:.2f}x downsampling)',
384
+ fontsize=13, fontweight='bold')
385
+ ax3.grid(True, alpha=0.3, axis='x', linestyle='--')
386
+ timeline_axes.append(ax3)
387
+ legend_row = 3
388
+ else:
389
+ legend_row = 2
390
+
391
+ ax_legend = fig.add_subplot(gs[legend_row])
392
+ ax_legend.axis('off')
393
+ legend_text = "Confidence: ■ High (avg attn > 0.5) ■ Medium (0.2-0.5) ■ Low (< 0.2)"
394
+ ax_legend.text(0.5, 0.5, legend_text, ha='center', va='center',
395
+ fontsize=11, transform=ax_legend.transAxes)
396
+
397
+ plt.tight_layout()
398
+ fig.canvas.draw()
399
+
400
+ ax1_pos = ax1.get_position()
401
+ renderer = fig.canvas.get_renderer()
402
+ ytick_extents = [tick.get_window_extent(renderer) for tick in ax1.get_yticklabels() if tick.get_text()]
403
+ fig_width_px = fig.get_size_inches()[0] * fig.dpi
404
+ if ytick_extents:
405
+ min_x_px = min(ext.x0 for ext in ytick_extents)
406
+ else:
407
+ min_x_px = ax1_pos.x0 * fig_width_px
408
+ line_x = max(0.01, (min_x_px / fig_width_px) - 0.01)
409
+ gw_center = 0.5 * (ax1_pos.y0 + ax1_pos.y1)
410
+ timeline_bounds = [ax.get_position() for ax in timeline_axes]
411
+ timeline_center = 0.5 * (min(pos.y0 for pos in timeline_bounds) + max(pos.y1 for pos in timeline_bounds))
412
+ fig.text(line_x, gw_center, 'Generated Word', rotation='vertical',
413
+ ha='right', va='center', fontsize=12, fontweight='bold')
414
+ fig.text(line_x, timeline_center, 'Timeline', rotation='vertical',
415
+ ha='right', va='center', fontsize=12, fontweight='bold')
416
+
417
+ png_path = Path(out_path)
418
+ plt.savefig(str(png_path), dpi=150, bbox_inches='tight')
419
+ pdf_path = png_path.with_suffix('.pdf')
420
+ plt.savefig(str(pdf_path), format='pdf', bbox_inches='tight')
421
+ plt.close()
422
+
423
+ print(f" ✓ {png_path.name} (PDF copy saved)")
424
+
425
+ render_alignment(output_path, latent_full_limit, orig_full_limit)
426
+
427
+ if latent_short_limit < latent_full_limit - 1e-6:
428
+ short_path = output_path.with_name("frame_alignment_short.png")
429
+ render_alignment(short_path, latent_short_limit, orig_short_limit if orig_short_limit else orig_full_limit)
430
 
431
  def save_alignment_data(self, output_path):
432
  """保存帧对齐数据为JSON"""