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

Improve the display effect of the picture

Browse files
Files changed (33) hide show
  1. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/analysis_report.txt +1 -1
  2. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_heatmap.pdf +0 -0
  3. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_heatmap.png +0 -0
  4. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_keyframes/keyframes_index.txt +1 -1
  5. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_weights.npy +0 -0
  6. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/debug_video_path.txt +0 -0
  7. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/feature_frame_mapping.json +0 -0
  8. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.json +0 -0
  9. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.pdf +0 -0
  10. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.png +2 -2
  11. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment_short.pdf +0 -0
  12. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment_short.png +2 -2
  13. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/gloss_to_frames.png +0 -0
  14. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/interactive_alignment.html +0 -0
  15. SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/translation.txt +0 -0
  16. SignX/detailed_prediction_20260101_150706/632051/analysis_report.txt +43 -0
  17. SignX/detailed_prediction_20260101_150706/632051/attention_heatmap.pdf +0 -0
  18. SignX/detailed_prediction_20260101_150706/632051/attention_heatmap.png +3 -0
  19. SignX/detailed_prediction_20260101_150706/632051/attention_keyframes/keyframes_index.txt +35 -0
  20. SignX/detailed_prediction_20260101_150706/632051/attention_weights.npy +3 -0
  21. SignX/detailed_prediction_20260101_150706/632051/debug_video_path.txt +4 -0
  22. SignX/detailed_prediction_20260101_150706/632051/feature_frame_mapping.json +176 -0
  23. SignX/detailed_prediction_20260101_150706/632051/frame_alignment.json +86 -0
  24. SignX/detailed_prediction_20260101_150706/632051/frame_alignment.pdf +0 -0
  25. SignX/detailed_prediction_20260101_150706/632051/frame_alignment.png +3 -0
  26. SignX/detailed_prediction_20260101_150706/632051/frame_alignment_short.pdf +0 -0
  27. SignX/detailed_prediction_20260101_150706/632051/frame_alignment_short.png +3 -0
  28. SignX/detailed_prediction_20260101_150706/632051/gloss_to_frames.png +3 -0
  29. SignX/detailed_prediction_20260101_150706/632051/interactive_alignment.html +579 -0
  30. SignX/detailed_prediction_20260101_150706/632051/translation.txt +3 -0
  31. SignX/eval/attention_analysis.py +65 -13
  32. SignX/inference_output.txt +1 -1
  33. SignX/inference_output.txt.clean +1 -1
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/analysis_report.txt RENAMED
@@ -2,7 +2,7 @@
2
  Sign Language Recognition - Attention分析报告
3
  ================================================================================
4
 
5
- 生成时间: 2026-01-01 13:38:55
6
 
7
  翻译结果:
8
  --------------------------------------------------------------------------------
 
2
  Sign Language Recognition - Attention分析报告
3
  ================================================================================
4
 
5
+ 生成时间: 2026-01-01 13:59:05
6
 
7
  翻译结果:
8
  --------------------------------------------------------------------------------
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_heatmap.pdf RENAMED
Binary files a/SignX/detailed_prediction_20260101_133848/3381121/attention_heatmap.pdf and b/SignX/detailed_prediction_20260101_135859/3381121/attention_heatmap.pdf differ
 
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/attention_heatmap.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/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_133848/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_135859/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_133848 → detailed_prediction_20260101_135859}/3381121/attention_weights.npy RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/debug_video_path.txt RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/feature_frame_mapping.json RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.json RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.pdf RENAMED
Binary files a/SignX/detailed_prediction_20260101_133848/3381121/frame_alignment.pdf and b/SignX/detailed_prediction_20260101_135859/3381121/frame_alignment.pdf differ
 
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment_short.pdf RENAMED
Binary files a/SignX/detailed_prediction_20260101_133848/3381121/frame_alignment_short.pdf and b/SignX/detailed_prediction_20260101_135859/3381121/frame_alignment_short.pdf differ
 
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/frame_alignment_short.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/gloss_to_frames.png RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/interactive_alignment.html RENAMED
File without changes
SignX/{detailed_prediction_20260101_133848 → detailed_prediction_20260101_135859}/3381121/translation.txt RENAMED
File without changes
SignX/detailed_prediction_20260101_150706/632051/analysis_report.txt ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ================================================================================
2
+ Sign Language Recognition - Attention分析报告
3
+ ================================================================================
4
+
5
+ 生成时间: 2026-01-01 15:07:12
6
+
7
+ 翻译结果:
8
+ --------------------------------------------------------------------------------
9
+ #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p
10
+
11
+ 视频信息:
12
+ --------------------------------------------------------------------------------
13
+ 总帧数: 28
14
+ 词数量: 8
15
+
16
+ Attention权重信息:
17
+ --------------------------------------------------------------------------------
18
+ 形状: (26, 28)
19
+ - 解码步数: 26
20
+
21
+ 词-帧对应详情:
22
+ ================================================================================
23
+ No. Word Frames Peak Attn Conf
24
+ --------------------------------------------------------------------------------
25
+ 1 #IF 2-2 2 0.472 medium
26
+ 2 FRIEND 5-5 5 0.425 medium
27
+ 3 GROUP/TOGETHER 8-8 8 0.375 medium
28
+ 4 DEPART 27-27 27 0.348 medium
29
+ 5 PARTY 27-27 27 0.383 medium
30
+ 6 IX-1p 27-27 27 0.333 medium
31
+ 7 JOIN 11-11 11 0.520 high
32
+ 8 IX-1p 14-14 14 0.368 medium
33
+
34
+ ================================================================================
35
+
36
+ 统计摘要:
37
+ --------------------------------------------------------------------------------
38
+ 平均attention权重: 0.403
39
+ 高置信度词: 1 (12.5%)
40
+ 中置信度词: 7 (87.5%)
41
+ 低置信度词: 0 (0.0%)
42
+
43
+ ================================================================================
SignX/detailed_prediction_20260101_150706/632051/attention_heatmap.pdf ADDED
Binary file (34.2 kB). View file
 
SignX/detailed_prediction_20260101_150706/632051/attention_heatmap.png ADDED

Git LFS Details

  • SHA256: 4918d39931330a20fd501a59f4b545a70a72fe2dc56effc29a49ffe18dd628e8
  • Pointer size: 130 Bytes
  • Size of remote file: 86.8 kB
SignX/detailed_prediction_20260101_150706/632051/attention_keyframes/keyframes_index.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 关键帧索引
2
+ ============================================================
3
+
4
+ 样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_150706/632051
5
+ 视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/videos/632051.mp4
6
+ 总关键帧数: 26
7
+
8
+ 关键帧列表:
9
+ ------------------------------------------------------------
10
+ Gloss 0: keyframe_000_feat2_frame9_att0.472.jpg
11
+ Gloss 1: keyframe_001_feat5_frame20_att0.425.jpg
12
+ Gloss 2: keyframe_002_feat8_frame32_att0.375.jpg
13
+ Gloss 3: keyframe_003_feat27_frame104_att0.348.jpg
14
+ Gloss 4: keyframe_004_feat27_frame104_att0.383.jpg
15
+ Gloss 5: keyframe_005_feat27_frame104_att0.333.jpg
16
+ Gloss 6: keyframe_006_feat11_frame43_att0.520.jpg
17
+ Gloss 7: keyframe_007_feat14_frame54_att0.368.jpg
18
+ Gloss 8: keyframe_008_feat17_frame66_att0.252.jpg
19
+ Gloss 9: keyframe_009_feat19_frame73_att0.884.jpg
20
+ Gloss 10: keyframe_010_feat0_frame1_att0.118.jpg
21
+ Gloss 11: keyframe_011_feat27_frame104_att0.164.jpg
22
+ Gloss 12: keyframe_012_feat25_frame96_att0.265.jpg
23
+ Gloss 13: keyframe_013_feat25_frame96_att0.282.jpg
24
+ Gloss 14: keyframe_014_feat25_frame96_att0.278.jpg
25
+ Gloss 15: keyframe_015_feat25_frame96_att0.277.jpg
26
+ Gloss 16: keyframe_016_feat27_frame104_att0.219.jpg
27
+ Gloss 17: keyframe_017_feat27_frame104_att0.190.jpg
28
+ Gloss 18: keyframe_018_feat27_frame104_att0.225.jpg
29
+ Gloss 19: keyframe_019_feat23_frame88_att0.150.jpg
30
+ Gloss 20: keyframe_020_feat27_frame104_att0.151.jpg
31
+ Gloss 21: keyframe_021_feat25_frame96_att0.360.jpg
32
+ Gloss 22: keyframe_022_feat25_frame96_att0.153.jpg
33
+ Gloss 23: keyframe_023_feat27_frame104_att0.144.jpg
34
+ Gloss 24: keyframe_024_feat25_frame96_att0.144.jpg
35
+ Gloss 25: keyframe_025_feat27_frame104_att0.186.jpg
SignX/detailed_prediction_20260101_150706/632051/attention_weights.npy ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d89932ced21ae95e0d7e034d8b3917146effa747bf7236c5eed30dd8cb9a258a
3
+ size 3040
SignX/detailed_prediction_20260101_150706/632051/debug_video_path.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ video_path = '/common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/videos/632051.mp4'
2
+ video_path type = <class 'str'>
3
+ video_path is None: False
4
+ bool(video_path): True
SignX/detailed_prediction_20260101_150706/632051/feature_frame_mapping.json ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "original_frame_count": 106,
3
+ "feature_count": 28,
4
+ "downsampling_ratio": 3.7857142857142856,
5
+ "fps": 24.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": 18,
35
+ "frame_count": 3
36
+ },
37
+ {
38
+ "feature_index": 5,
39
+ "frame_start": 18,
40
+ "frame_end": 22,
41
+ "frame_count": 4
42
+ },
43
+ {
44
+ "feature_index": 6,
45
+ "frame_start": 22,
46
+ "frame_end": 26,
47
+ "frame_count": 4
48
+ },
49
+ {
50
+ "feature_index": 7,
51
+ "frame_start": 26,
52
+ "frame_end": 30,
53
+ "frame_count": 4
54
+ },
55
+ {
56
+ "feature_index": 8,
57
+ "frame_start": 30,
58
+ "frame_end": 34,
59
+ "frame_count": 4
60
+ },
61
+ {
62
+ "feature_index": 9,
63
+ "frame_start": 34,
64
+ "frame_end": 37,
65
+ "frame_count": 3
66
+ },
67
+ {
68
+ "feature_index": 10,
69
+ "frame_start": 37,
70
+ "frame_end": 41,
71
+ "frame_count": 4
72
+ },
73
+ {
74
+ "feature_index": 11,
75
+ "frame_start": 41,
76
+ "frame_end": 45,
77
+ "frame_count": 4
78
+ },
79
+ {
80
+ "feature_index": 12,
81
+ "frame_start": 45,
82
+ "frame_end": 49,
83
+ "frame_count": 4
84
+ },
85
+ {
86
+ "feature_index": 13,
87
+ "frame_start": 49,
88
+ "frame_end": 53,
89
+ "frame_count": 4
90
+ },
91
+ {
92
+ "feature_index": 14,
93
+ "frame_start": 53,
94
+ "frame_end": 56,
95
+ "frame_count": 3
96
+ },
97
+ {
98
+ "feature_index": 15,
99
+ "frame_start": 56,
100
+ "frame_end": 60,
101
+ "frame_count": 4
102
+ },
103
+ {
104
+ "feature_index": 16,
105
+ "frame_start": 60,
106
+ "frame_end": 64,
107
+ "frame_count": 4
108
+ },
109
+ {
110
+ "feature_index": 17,
111
+ "frame_start": 64,
112
+ "frame_end": 68,
113
+ "frame_count": 4
114
+ },
115
+ {
116
+ "feature_index": 18,
117
+ "frame_start": 68,
118
+ "frame_end": 71,
119
+ "frame_count": 3
120
+ },
121
+ {
122
+ "feature_index": 19,
123
+ "frame_start": 71,
124
+ "frame_end": 75,
125
+ "frame_count": 4
126
+ },
127
+ {
128
+ "feature_index": 20,
129
+ "frame_start": 75,
130
+ "frame_end": 79,
131
+ "frame_count": 4
132
+ },
133
+ {
134
+ "feature_index": 21,
135
+ "frame_start": 79,
136
+ "frame_end": 83,
137
+ "frame_count": 4
138
+ },
139
+ {
140
+ "feature_index": 22,
141
+ "frame_start": 83,
142
+ "frame_end": 87,
143
+ "frame_count": 4
144
+ },
145
+ {
146
+ "feature_index": 23,
147
+ "frame_start": 87,
148
+ "frame_end": 90,
149
+ "frame_count": 3
150
+ },
151
+ {
152
+ "feature_index": 24,
153
+ "frame_start": 90,
154
+ "frame_end": 94,
155
+ "frame_count": 4
156
+ },
157
+ {
158
+ "feature_index": 25,
159
+ "frame_start": 94,
160
+ "frame_end": 98,
161
+ "frame_count": 4
162
+ },
163
+ {
164
+ "feature_index": 26,
165
+ "frame_start": 98,
166
+ "frame_end": 102,
167
+ "frame_count": 4
168
+ },
169
+ {
170
+ "feature_index": 27,
171
+ "frame_start": 102,
172
+ "frame_end": 106,
173
+ "frame_count": 4
174
+ }
175
+ ]
176
+ }
SignX/detailed_prediction_20260101_150706/632051/frame_alignment.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "translation": "#IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p",
3
+ "words": [
4
+ "#IF",
5
+ "FRIEND",
6
+ "GROUP/TOGETHER",
7
+ "DEPART",
8
+ "PARTY",
9
+ "IX-1p",
10
+ "JOIN",
11
+ "IX-1p"
12
+ ],
13
+ "total_video_frames": 28,
14
+ "frame_ranges": [
15
+ {
16
+ "word": "#IF",
17
+ "start_frame": 2,
18
+ "end_frame": 2,
19
+ "peak_frame": 2,
20
+ "avg_attention": 0.47214657068252563,
21
+ "confidence": "medium"
22
+ },
23
+ {
24
+ "word": "FRIEND",
25
+ "start_frame": 5,
26
+ "end_frame": 5,
27
+ "peak_frame": 5,
28
+ "avg_attention": 0.4252290427684784,
29
+ "confidence": "medium"
30
+ },
31
+ {
32
+ "word": "GROUP/TOGETHER",
33
+ "start_frame": 8,
34
+ "end_frame": 8,
35
+ "peak_frame": 8,
36
+ "avg_attention": 0.37518179416656494,
37
+ "confidence": "medium"
38
+ },
39
+ {
40
+ "word": "DEPART",
41
+ "start_frame": 27,
42
+ "end_frame": 27,
43
+ "peak_frame": 27,
44
+ "avg_attention": 0.3480324149131775,
45
+ "confidence": "medium"
46
+ },
47
+ {
48
+ "word": "PARTY",
49
+ "start_frame": 27,
50
+ "end_frame": 27,
51
+ "peak_frame": 27,
52
+ "avg_attention": 0.38299673795700073,
53
+ "confidence": "medium"
54
+ },
55
+ {
56
+ "word": "IX-1p",
57
+ "start_frame": 27,
58
+ "end_frame": 27,
59
+ "peak_frame": 27,
60
+ "avg_attention": 0.33272165060043335,
61
+ "confidence": "medium"
62
+ },
63
+ {
64
+ "word": "JOIN",
65
+ "start_frame": 11,
66
+ "end_frame": 11,
67
+ "peak_frame": 11,
68
+ "avg_attention": 0.5199229121208191,
69
+ "confidence": "high"
70
+ },
71
+ {
72
+ "word": "IX-1p",
73
+ "start_frame": 14,
74
+ "end_frame": 14,
75
+ "peak_frame": 14,
76
+ "avg_attention": 0.3677118122577667,
77
+ "confidence": "medium"
78
+ }
79
+ ],
80
+ "statistics": {
81
+ "avg_confidence": 0.4029928669333458,
82
+ "high_confidence_words": 1,
83
+ "medium_confidence_words": 7,
84
+ "low_confidence_words": 0
85
+ }
86
+ }
SignX/detailed_prediction_20260101_150706/632051/frame_alignment.pdf ADDED
Binary file (32.8 kB). View file
 
SignX/detailed_prediction_20260101_150706/632051/frame_alignment.png ADDED

Git LFS Details

  • SHA256: fae98c036206ccc07cb2a724ea724c53292acd0cc63d464bfef3ca1fc9ec7ba0
  • Pointer size: 131 Bytes
  • Size of remote file: 153 kB
SignX/detailed_prediction_20260101_150706/632051/frame_alignment_short.pdf ADDED
Binary file (32.2 kB). View file
 
SignX/detailed_prediction_20260101_150706/632051/frame_alignment_short.png ADDED

Git LFS Details

  • SHA256: 0cc1e163cc2cdff156c73e48136bef57a7f8372b89c8242572b38c5c14cb17bb
  • Pointer size: 131 Bytes
  • Size of remote file: 152 kB
SignX/detailed_prediction_20260101_150706/632051/gloss_to_frames.png ADDED

Git LFS Details

  • SHA256: b147ca7e50fac483f6862169e2e9ee78f726fa591bbf99979612d99187af71ef
  • Pointer size: 132 Bytes
  • Size of remote file: 3.6 MB
SignX/detailed_prediction_20260101_150706/632051/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> #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p<br>
139
+ <strong>Total Words:</strong> 8 |
140
+ <strong>Total Features:</strong> 28
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": "#IF", "word_idx": 0, "weights": [0.013499895110726357, 0.02982642501592636, 0.47214657068252563, 0.4107391834259033, 0.04950176924467087, 0.011385880410671234, 0.007043282967060804, 0.0014652750687673688, 0.0005238102748990059, 0.00040972864371724427, 0.0001160625834017992, 6.416538963094354e-05, 5.9505786339286715e-05, 5.076597517472692e-05, 6.82844765833579e-05, 0.00012157609307905659, 6.597878382308409e-05, 0.00010269331687595695, 0.00013462362403515726, 6.423696322599426e-05, 8.642762986710295e-05, 9.25226995605044e-05, 0.00011670421372400597, 0.0001578366500325501, 0.00020240909361746162, 0.0003825947642326355, 0.0007172566256485879, 0.0008544913143850863]}, {"word": "FRIEND", "word_idx": 1, "weights": [0.009660173207521439, 0.010518566705286503, 0.011222519911825657, 0.014483344741165638, 0.1795402616262436, 0.4252290427684784, 0.25737643241882324, 0.05393827706575394, 0.01512613520026207, 0.013365501537919044, 0.002376752672716975, 0.00014935070066712797, 8.692959818290547e-05, 0.0004998841905035079, 0.0008451194153167307, 0.0011626698542386293, 0.00042453958303667605, 0.00017692227265797555, 0.00016767902707215399, 4.8644251364748925e-05, 8.348096889676526e-05, 0.0001094180770451203, 0.00030694258748553693, 0.0002885134017560631, 0.00031121523352339864, 0.0006241592927835882, 0.0008697768207639456, 0.0010077793849632144]}, {"word": "GROUP/TOGETHER", "word_idx": 2, "weights": [0.010994982905685902, 0.004551935940980911, 0.002873026067391038, 0.003936904948204756, 0.008626177906990051, 0.014811795204877853, 0.02318989858031273, 0.12032425403594971, 0.37518179416656494, 0.2971201539039612, 0.08549409359693527, 0.014250868931412697, 0.008063109591603279, 0.00339426938444376, 0.0037573552690446377, 0.004879903048276901, 0.0018731161253526807, 0.0011690640822052956, 0.0013268929906189442, 0.0007135092164389789, 0.000632062554359436, 0.000777124660089612, 0.0009553946438245475, 0.0009487943025305867, 0.0007010120898485184, 0.001496487995609641, 0.0037835948169231415, 0.004172381013631821]}, {"word": "DEPART", "word_idx": 3, "weights": [0.22514434158802032, 0.12377114593982697, 0.00781786348670721, 0.0074639273807406425, 0.01298774778842926, 0.00438598683103919, 0.004350316245108843, 0.006786263547837734, 0.006216868292540312, 0.0061629218980669975, 0.004193580709397793, 0.0015793128404766321, 0.0011525226291269064, 0.0014239393640309572, 0.0007423617644235492, 0.0008507575839757919, 0.0008870838792063296, 0.00024679809575900435, 0.00034805957693606615, 0.005230794660747051, 0.0011639633448794484, 0.001367528340779245, 0.010013289749622345, 0.018452608957886696, 0.0018141826149076223, 0.001117207808420062, 0.19629621505737305, 0.3480324149131775]}, {"word": "PARTY", "word_idx": 4, "weights": [0.1664648950099945, 0.06123431771993637, 0.0020844682585448027, 0.0020428383722901344, 0.0058554718270897865, 0.004360921215265989, 0.004692059941589832, 0.009323552250862122, 0.015183845534920692, 0.016528787091374397, 0.015347503125667572, 0.007253072690218687, 0.005231750197708607, 0.009598116390407085, 0.00704572768881917, 0.007053114008158445, 0.006423295009881258, 0.0010452027199789882, 0.0009786873124539852, 0.004494669381529093, 0.005323153454810381, 0.006433582864701748, 0.022334398701786995, 0.03912580758333206, 0.004556183237582445, 0.0021732028108090162, 0.18481463193893433, 0.38299673795700073]}, {"word": "IX-1p", "word_idx": 5, "weights": [0.2268882542848587, 0.10439852625131607, 0.005018203519284725, 0.005008632782846689, 0.005379822570830584, 0.00215631234459579, 0.0024426421150565147, 0.007580526173114777, 0.011461855843663216, 0.010575865395367146, 0.010204891674220562, 0.004322281572967768, 0.0023845669347792864, 0.0016265056328848004, 0.0011272492120042443, 0.0014091862831264734, 0.0019118450582027435, 0.0019068039255216718, 0.002558623207733035, 0.005466249771416187, 0.002576562575995922, 0.0033958060666918755, 0.014094071462750435, 0.03357496112585068, 0.005502632353454828, 0.003941097296774387, 0.19036439061164856, 0.33272165060043335]}, {"word": "JOIN", "word_idx": 6, "weights": [0.006536237895488739, 0.002151536289602518, 0.0006580766057595611, 0.0008207014761865139, 0.0003112705599050969, 0.0003111894184257835, 0.0008894064230844378, 0.004121360369026661, 0.01069970428943634, 0.008291625417768955, 0.01931559480726719, 0.5199229121208191, 0.40212148427963257, 0.004480497911572456, 0.0010337198618799448, 0.0007998707587830722, 0.00024323497200384736, 7.284984894795343e-05, 0.00011325528612360358, 0.00540410028770566, 0.0011726750526577234, 0.0009422790608368814, 0.0003188242844771594, 0.00024731658049859107, 3.1396619306178764e-05, 4.355102646513842e-05, 0.0036189379170536995, 0.005326398182660341]}, {"word": "IX-1p", "word_idx": 7, "weights": [0.0013159031514078379, 0.0007256589597091079, 0.00017777174070943147, 0.0001744187029544264, 0.00025140171055682003, 0.00039260604535229504, 0.0003829205525107682, 0.000333531730575487, 0.0007308170897886157, 0.0010108469286933541, 0.0015992401167750359, 0.003526317421346903, 0.012568545527756214, 0.2852487564086914, 0.3677118122577667, 0.19535787403583527, 0.07697467505931854, 0.012815488502383232, 0.007124335505068302, 0.0009805350564420223, 0.007633780129253864, 0.007437399588525295, 0.005485337693244219, 0.003693929873406887, 0.0026681837625801563, 0.0011110405903309584, 0.0008843602845445275, 0.0016825739294290543]}];
211
+ const numGlosses = 8;
212
+ const numFeatures = 28;
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_150706/632051/translation.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ With BPE: #IF FRIEND GROUP/TOGE@@ TH@@ E@@ R DEPART PARTY IX-1p JO@@ I@@ N IX-1p
2
+ Clean: #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p
3
+ Ground Truth: #IF FRIEND GROUP/TOGETHER GO-OUT PARTY IX-1p JOIN IX-1p
SignX/eval/attention_analysis.py CHANGED
@@ -82,6 +82,7 @@ class AttentionAnalyzer:
82
 
83
  # 计算词-帧对应关系
84
  self.word_frame_ranges = self._compute_word_frame_ranges()
 
85
 
86
  def _compute_word_frame_ranges(self):
87
  """
@@ -153,6 +154,54 @@ class AttentionAnalyzer:
153
 
154
  return word_ranges
155
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  def generate_all_visualizations(self, output_dir):
157
  """
158
  生成所有可视化图表
@@ -280,6 +329,7 @@ class AttentionAnalyzer:
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', [])
@@ -287,14 +337,15 @@ class AttentionAnalyzer:
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])
@@ -354,6 +405,11 @@ class AttentionAnalyzer:
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:
@@ -383,16 +439,12 @@ class AttentionAnalyzer:
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()
 
82
 
83
  # 计算词-帧对应关系
84
  self.word_frame_ranges = self._compute_word_frame_ranges()
85
+ self.frame_attention_strength = self._compute_frame_attention_strength()
86
 
87
  def _compute_word_frame_ranges(self):
88
  """
 
154
 
155
  return word_ranges
156
 
157
+ def _compute_frame_attention_strength(self):
158
+ """Compute average attention per feature frame (normalized 0-1)."""
159
+ if self.attn_best.size == 0:
160
+ return np.zeros(self.video_frames, dtype=np.float32)
161
+
162
+ if self.attn_best.ndim == 1:
163
+ frame_strength = self.attn_best.copy()
164
+ else:
165
+ frame_strength = self.attn_best.mean(axis=0)
166
+
167
+ if frame_strength.shape[0] != self.video_frames:
168
+ frame_strength = np.resize(frame_strength, self.video_frames)
169
+
170
+ max_val = frame_strength.max()
171
+ if max_val > 0:
172
+ frame_strength = frame_strength / max_val
173
+ return frame_strength
174
+
175
+ def _map_strength_to_original_frames(self, mapping_list, original_frame_count):
176
+ """Map latent attention strength to original video frame resolution."""
177
+ if not mapping_list or original_frame_count <= 0:
178
+ return None
179
+
180
+ orig_strength = np.zeros(original_frame_count, dtype=np.float32)
181
+ counts = np.zeros(original_frame_count, dtype=np.float32)
182
+
183
+ for feat_idx, mapping in enumerate(mapping_list):
184
+ if feat_idx >= len(self.frame_attention_strength):
185
+ break
186
+ start = int(mapping.get('frame_start', 0))
187
+ end = int(mapping.get('frame_end', start))
188
+ end = max(end, start + 1)
189
+ start = max(start, 0)
190
+ end = min(end, original_frame_count)
191
+ if start >= end:
192
+ continue
193
+ orig_strength[start:end] += self.frame_attention_strength[feat_idx]
194
+ counts[start:end] += 1
195
+
196
+ mask = counts > 0
197
+ if mask.any():
198
+ orig_strength[mask] = orig_strength[mask] / counts[mask]
199
+
200
+ max_val = orig_strength.max()
201
+ if max_val > 0:
202
+ orig_strength = orig_strength / max_val
203
+ return orig_strength
204
+
205
  def generate_all_visualizations(self, output_dir):
206
  """
207
  生成所有可视化图表
 
329
  mapping_list = None
330
  orig_full_limit = None
331
  orig_short_limit = None
332
+ pixel_strength_curve = None
333
  if feature_mapping:
334
  original_frame_count = feature_mapping.get('original_frame_count', self.video_frames)
335
  mapping_list = feature_mapping.get('mapping', [])
 
337
  if mapping_list:
338
  idx = min(max_feat_end, len(mapping_list) - 1)
339
  orig_short_limit = mapping_list[idx]['frame_end'] + 2
340
+ pixel_strength_curve = self._map_strength_to_original_frames(mapping_list, original_frame_count)
341
 
342
  def render_alignment(out_path, latent_xlim_end, orig_xlim_end=None):
343
  if feature_mapping:
344
+ fig = plt.figure(figsize=(18, 9))
345
+ gs = GridSpec(3, 1, height_ratios=[4, 1, 1], hspace=0.32)
346
  else:
347
+ fig = plt.figure(figsize=(18, 7.5))
348
+ gs = GridSpec(2, 1, height_ratios=[4, 1], hspace=0.32)
349
 
350
  # === 上图: 词-帧对齐 ===
351
  ax1 = fig.add_subplot(gs[0])
 
405
  ax2.set_title('Latent Feature Timeline', fontsize=13, fontweight='bold')
406
  ax2.grid(True, alpha=0.3, axis='x', linestyle='--')
407
 
408
+ if self.frame_attention_strength is not None and len(self.frame_attention_strength) >= self.video_frames:
409
+ latent_curve_x = np.arange(self.video_frames)
410
+ latent_curve_y = self.frame_attention_strength[:self.video_frames] * 0.6 - 0.3
411
+ ax2.plot(latent_curve_x, latent_curve_y, color='#E53935', linewidth=1.5, alpha=0.9)
412
+
413
  timeline_axes = [ax2]
414
 
415
  if feature_mapping:
 
439
  f'{feature_mapping["downsampling_ratio"]:.2f}x downsampling)',
440
  fontsize=13, fontweight='bold')
441
  ax3.grid(True, alpha=0.3, axis='x', linestyle='--')
 
 
 
 
442
 
443
+ if pixel_strength_curve is not None and len(pixel_strength_curve) >= original_frame_count:
444
+ pixel_curve_x = np.arange(original_frame_count)
445
+ pixel_curve_y = pixel_strength_curve[:original_frame_count] * 0.6 - 0.3
446
+ ax3.plot(pixel_curve_x, pixel_curve_y, color='#E53935', linewidth=1.5, alpha=0.9)
447
+ timeline_axes.append(ax3)
448
 
449
  plt.tight_layout()
450
  fig.canvas.draw()
SignX/inference_output.txt CHANGED
@@ -1 +1 @@
1
- BOX/ROOM I@@ X NOT-YET ARRIVE I@@ X SHOULD CONT@@ ACT ns-fs-@@ F@@ E@@ DE@@ X
 
1
+ #IF FRIEND GROUP/TOGE@@ TH@@ E@@ R DEPART PARTY IX-1p JO@@ I@@ N IX-1p
SignX/inference_output.txt.clean CHANGED
@@ -1 +1 @@
1
- BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX
 
1
+ #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p