diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/analysis_report.txt b/SignX/detailed_prediction_20260101_114639/sample_000/analysis_report.txt new file mode 100644 index 0000000000000000000000000000000000000000..4fd612a03d13ee29648cf2ff52653f07c26f5a5a --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/analysis_report.txt @@ -0,0 +1,43 @@ +================================================================================ + Sign Language Recognition - Attention分析报告 +================================================================================ + +生成时间: 2026-01-01 11:46:42 + +翻译结果: +-------------------------------------------------------------------------------- +#IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p + +视频信息: +-------------------------------------------------------------------------------- +总帧数: 28 +词数量: 8 + +Attention权重信息: +-------------------------------------------------------------------------------- +形状: (26, 28) + - 解码步数: 26 + +词-帧对应详情: +================================================================================ +No. Word Frames Peak Attn Conf +-------------------------------------------------------------------------------- +1 #IF 2-2 2 0.472 medium +2 FRIEND 5-5 5 0.425 medium +3 GROUP/TOGETHER 8-8 8 0.375 medium +4 DEPART 27-27 27 0.348 medium +5 PARTY 27-27 27 0.383 medium +6 IX-1p 27-27 27 0.333 medium +7 JOIN 11-11 11 0.520 high +8 IX-1p 14-14 14 0.368 medium + +================================================================================ + +统计摘要: +-------------------------------------------------------------------------------- +平均attention权重: 0.403 +高置信度词: 1 (12.5%) +中置信度词: 7 (87.5%) +低置信度词: 0 (0.0%) + +================================================================================ diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/attention_heatmap.png b/SignX/detailed_prediction_20260101_114639/sample_000/attention_heatmap.png new file mode 100644 index 0000000000000000000000000000000000000000..1a719e848d0196e0fcd70623ff15adfba1cd10d9 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/attention_heatmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4918d39931330a20fd501a59f4b545a70a72fe2dc56effc29a49ffe18dd628e8 +size 86847 diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/attention_keyframes/keyframes_index.txt b/SignX/detailed_prediction_20260101_114639/sample_000/attention_keyframes/keyframes_index.txt new file mode 100644 index 0000000000000000000000000000000000000000..18ce35a5f4c9bdbf9513c2c4182d7eed407a38fe --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/attention_keyframes/keyframes_index.txt @@ -0,0 +1,35 @@ +关键帧索引 +============================================================ + +样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_114639/sample_000 +视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/videos/632051.mp4 +总关键帧数: 26 + +关键帧列表: +------------------------------------------------------------ +Gloss 0: keyframe_000_feat2_frame9_att0.472.jpg +Gloss 1: keyframe_001_feat5_frame20_att0.425.jpg +Gloss 2: keyframe_002_feat8_frame32_att0.375.jpg +Gloss 3: keyframe_003_feat27_frame104_att0.348.jpg +Gloss 4: keyframe_004_feat27_frame104_att0.383.jpg +Gloss 5: keyframe_005_feat27_frame104_att0.333.jpg +Gloss 6: keyframe_006_feat11_frame43_att0.520.jpg +Gloss 7: keyframe_007_feat14_frame54_att0.368.jpg +Gloss 8: keyframe_008_feat17_frame66_att0.252.jpg +Gloss 9: keyframe_009_feat19_frame73_att0.884.jpg +Gloss 10: keyframe_010_feat0_frame1_att0.118.jpg +Gloss 11: keyframe_011_feat27_frame104_att0.164.jpg +Gloss 12: keyframe_012_feat25_frame96_att0.265.jpg +Gloss 13: keyframe_013_feat25_frame96_att0.282.jpg +Gloss 14: keyframe_014_feat25_frame96_att0.278.jpg +Gloss 15: keyframe_015_feat25_frame96_att0.277.jpg +Gloss 16: keyframe_016_feat27_frame104_att0.219.jpg +Gloss 17: keyframe_017_feat27_frame104_att0.190.jpg +Gloss 18: keyframe_018_feat27_frame104_att0.225.jpg +Gloss 19: keyframe_019_feat23_frame88_att0.150.jpg +Gloss 20: keyframe_020_feat27_frame104_att0.151.jpg +Gloss 21: keyframe_021_feat25_frame96_att0.360.jpg +Gloss 22: keyframe_022_feat25_frame96_att0.153.jpg +Gloss 23: keyframe_023_feat27_frame104_att0.144.jpg +Gloss 24: keyframe_024_feat25_frame96_att0.144.jpg +Gloss 25: keyframe_025_feat27_frame104_att0.186.jpg diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/attention_weights.npy b/SignX/detailed_prediction_20260101_114639/sample_000/attention_weights.npy new file mode 100644 index 0000000000000000000000000000000000000000..f56bd7427c24cf25007a7a112551a71bd2417800 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/attention_weights.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d89932ced21ae95e0d7e034d8b3917146effa747bf7236c5eed30dd8cb9a258a +size 3040 diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/debug_video_path.txt b/SignX/detailed_prediction_20260101_114639/sample_000/debug_video_path.txt new file mode 100644 index 0000000000000000000000000000000000000000..f208033107cba1f24c0a77081690bdffaef46d0c --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/debug_video_path.txt @@ -0,0 +1,4 @@ +video_path = '/common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/videos/632051.mp4' +video_path type = +video_path is None: False +bool(video_path): True diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/feature_frame_mapping.json b/SignX/detailed_prediction_20260101_114639/sample_000/feature_frame_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..494292631f7cb077fc0dda48207fd4be95d7be68 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/feature_frame_mapping.json @@ -0,0 +1,176 @@ +{ + "original_frame_count": 106, + "feature_count": 28, + "downsampling_ratio": 3.7857142857142856, + "fps": 24.0, + "mapping": [ + { + "feature_index": 0, + "frame_start": 0, + "frame_end": 3, + "frame_count": 3 + }, + { + "feature_index": 1, + "frame_start": 3, + "frame_end": 7, + "frame_count": 4 + }, + { + "feature_index": 2, + "frame_start": 7, + "frame_end": 11, + "frame_count": 4 + }, + { + "feature_index": 3, + "frame_start": 11, + "frame_end": 15, + "frame_count": 4 + }, + { + "feature_index": 4, + "frame_start": 15, + "frame_end": 18, + "frame_count": 3 + }, + { + "feature_index": 5, + "frame_start": 18, + "frame_end": 22, + "frame_count": 4 + }, + { + "feature_index": 6, + "frame_start": 22, + "frame_end": 26, + "frame_count": 4 + }, + { + "feature_index": 7, + "frame_start": 26, + "frame_end": 30, + "frame_count": 4 + }, + { + "feature_index": 8, + "frame_start": 30, + "frame_end": 34, + "frame_count": 4 + }, + { + "feature_index": 9, + "frame_start": 34, + "frame_end": 37, + "frame_count": 3 + }, + { + "feature_index": 10, + "frame_start": 37, + "frame_end": 41, + "frame_count": 4 + }, + { + "feature_index": 11, + "frame_start": 41, + "frame_end": 45, + "frame_count": 4 + }, + { + "feature_index": 12, + "frame_start": 45, + "frame_end": 49, + "frame_count": 4 + }, + { + "feature_index": 13, + "frame_start": 49, + "frame_end": 53, + "frame_count": 4 + }, + { + "feature_index": 14, + "frame_start": 53, + "frame_end": 56, + "frame_count": 3 + }, + { + "feature_index": 15, + "frame_start": 56, + "frame_end": 60, + "frame_count": 4 + }, + { + "feature_index": 16, + "frame_start": 60, + "frame_end": 64, + "frame_count": 4 + }, + { + "feature_index": 17, + "frame_start": 64, + "frame_end": 68, + "frame_count": 4 + }, + { + "feature_index": 18, + "frame_start": 68, + "frame_end": 71, + "frame_count": 3 + }, + { + "feature_index": 19, + "frame_start": 71, + "frame_end": 75, + "frame_count": 4 + }, + { + "feature_index": 20, + "frame_start": 75, + "frame_end": 79, + "frame_count": 4 + }, + { + "feature_index": 21, + "frame_start": 79, + "frame_end": 83, + "frame_count": 4 + }, + { + "feature_index": 22, + "frame_start": 83, + "frame_end": 87, + "frame_count": 4 + }, + { + "feature_index": 23, + "frame_start": 87, + "frame_end": 90, + "frame_count": 3 + }, + { + "feature_index": 24, + "frame_start": 90, + "frame_end": 94, + "frame_count": 4 + }, + { + "feature_index": 25, + "frame_start": 94, + "frame_end": 98, + "frame_count": 4 + }, + { + "feature_index": 26, + "frame_start": 98, + "frame_end": 102, + "frame_count": 4 + }, + { + "feature_index": 27, + "frame_start": 102, + "frame_end": 106, + "frame_count": 4 + } + ] +} \ No newline at end of file diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.json b/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.json new file mode 100644 index 0000000000000000000000000000000000000000..487e282fb47a609c064eaafa7771300ceaf2e457 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.json @@ -0,0 +1,86 @@ +{ + "translation": "#IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p", + "words": [ + "#IF", + "FRIEND", + "GROUP/TOGETHER", + "DEPART", + "PARTY", + "IX-1p", + "JOIN", + "IX-1p" + ], + "total_video_frames": 28, + "frame_ranges": [ + { + "word": "#IF", + "start_frame": 2, + "end_frame": 2, + "peak_frame": 2, + "avg_attention": 0.47214657068252563, + "confidence": "medium" + }, + { + "word": "FRIEND", + "start_frame": 5, + "end_frame": 5, + "peak_frame": 5, + "avg_attention": 0.4252290427684784, + "confidence": "medium" + }, + { + "word": "GROUP/TOGETHER", + "start_frame": 8, + "end_frame": 8, + "peak_frame": 8, + "avg_attention": 0.37518179416656494, + "confidence": "medium" + }, + { + "word": "DEPART", + "start_frame": 27, + "end_frame": 27, + "peak_frame": 27, + "avg_attention": 0.3480324149131775, + "confidence": "medium" + }, + { + "word": "PARTY", + "start_frame": 27, + "end_frame": 27, + "peak_frame": 27, + "avg_attention": 0.38299673795700073, + "confidence": "medium" + }, + { + "word": "IX-1p", + "start_frame": 27, + "end_frame": 27, + "peak_frame": 27, + "avg_attention": 0.33272165060043335, + "confidence": "medium" + }, + { + "word": "JOIN", + "start_frame": 11, + "end_frame": 11, + "peak_frame": 11, + "avg_attention": 0.5199229121208191, + "confidence": "high" + }, + { + "word": "IX-1p", + "start_frame": 14, + "end_frame": 14, + "peak_frame": 14, + "avg_attention": 0.3677118122577667, + "confidence": "medium" + } + ], + "statistics": { + "avg_confidence": 0.4029928669333458, + "high_confidence_words": 1, + "medium_confidence_words": 7, + "low_confidence_words": 0 + } +} \ No newline at end of file diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.png b/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.png new file mode 100644 index 0000000000000000000000000000000000000000..bf9077709b51bd3721da9e217cb27238af475bbd --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/frame_alignment.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7b3166edb1add7d66c39ab764a7c8b75fdd5753f53dd2679af49cf8827526622 +size 150665 diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/gloss_to_frames.png b/SignX/detailed_prediction_20260101_114639/sample_000/gloss_to_frames.png new file mode 100644 index 0000000000000000000000000000000000000000..df68b47e19261d5aef15d1daf098e428ec6cc25a --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/gloss_to_frames.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b147ca7e50fac483f6862169e2e9ee78f726fa591bbf99979612d99187af71ef +size 3596925 diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/interactive_alignment.html b/SignX/detailed_prediction_20260101_114639/sample_000/interactive_alignment.html new file mode 100644 index 0000000000000000000000000000000000000000..2eb2f43f2d09bd068820318502e5bf9b81c2c062 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/interactive_alignment.html @@ -0,0 +1,579 @@ + + + + + + Interactive Word-Frame Alignment + + + +
+

🎯 Interactive Word-to-Frame Alignment Visualizer

+ +
+ Translation: #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p
+ Total Words: 8 | + Total Features: 28 +
+ +
+

⚙️ Threshold Controls

+ +
+ + + 90% +
+ + 帧的注意力权重 ≥ (峰值权重 × 阈值%) 时被认为是"显著帧" + +
+ +
+ + + 0.50 +
+ +
+ + + 0.20 +
+ + +
+ +
+

Word-to-Frame Alignment

+

+ 每个词显示为彩色矩形,宽度表示该词对应的特征帧范围。★ = 峰值帧。矩形内部显示注意力权重波形。 +

+ + +

Timeline Progress Bar

+ + +
+ Legend:

+
+ High + Medium + Low + Confidence Levels (opacity reflects confidence) +
+
+ + Peak Frame (highest attention) +
+
+ + Attention Waveform (within word region) +
+
+
+ +
+

Alignment Details

+
+
+
+ + + + diff --git a/SignX/detailed_prediction_20260101_114639/sample_000/translation.txt b/SignX/detailed_prediction_20260101_114639/sample_000/translation.txt new file mode 100644 index 0000000000000000000000000000000000000000..4f614772f0263440df6a30820643afe5ef986e58 --- /dev/null +++ b/SignX/detailed_prediction_20260101_114639/sample_000/translation.txt @@ -0,0 +1,2 @@ +With BPE: #IF FRIEND GROUP/TOGE@@ TH@@ E@@ R DEPART PARTY IX-1p JO@@ I@@ N IX-1p +Clean: #IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p diff --git a/SignX/detailed_prediction_20260101_131106/3381121/analysis_report.txt b/SignX/detailed_prediction_20260101_131106/3381121/analysis_report.txt new file mode 100644 index 0000000000000000000000000000000000000000..a191fa23677766be2efd1d3511b146b12bec62fe --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/analysis_report.txt @@ -0,0 +1,43 @@ +================================================================================ + Sign Language Recognition - Attention分析报告 +================================================================================ + +生成时间: 2026-01-01 13:11:10 + +翻译结果: +-------------------------------------------------------------------------------- +BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX + +视频信息: +-------------------------------------------------------------------------------- +总帧数: 35 +词数量: 8 + +Attention权重信息: +-------------------------------------------------------------------------------- +形状: (30, 35) + - 解码步数: 30 + +词-帧对应详情: +================================================================================ +No. Word Frames Peak Attn Conf +-------------------------------------------------------------------------------- +1 BOX/ROOM 4-4 4 0.618 high +2 IX 7-7 7 0.524 high +3 NOT-YET 7-7 7 0.266 medium +4 ARRIVE 8-10 8 0.308 medium +5 IX 11-11 11 0.486 medium +6 SHOULD 13-13 13 0.595 high +7 CONTACT 13-13 13 0.179 low +8 ns-fs-FEDEX 17-17 17 0.761 high + +================================================================================ + +统计摘要: +-------------------------------------------------------------------------------- +平均attention权重: 0.467 +高置信度词: 4 (50.0%) +中置信度词: 3 (37.5%) +低置信度词: 1 (12.5%) + +================================================================================ diff --git a/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.pdf b/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.pdf new file mode 100644 index 0000000000000000000000000000000000000000..0492b14504d996f3608c7a6f8026f36d4050d693 Binary files /dev/null and b/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.pdf differ diff --git a/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.png b/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.png new file mode 100644 index 0000000000000000000000000000000000000000..8fbceffe3a394d91351c0ec90a8e006dde813ed1 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/attention_heatmap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ef8392c2b7438bd5eed3d032dd64084eab2c49f3c825752ebaccc6657d73ee2 +size 90071 diff --git a/SignX/detailed_prediction_20260101_131106/3381121/attention_keyframes/keyframes_index.txt b/SignX/detailed_prediction_20260101_131106/3381121/attention_keyframes/keyframes_index.txt new file mode 100644 index 0000000000000000000000000000000000000000..29160533d0b58cbf694ce91ad1fb67e5044923a1 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/attention_keyframes/keyframes_index.txt @@ -0,0 +1,39 @@ +关键帧索引 +============================================================ + +样本目录: /common/users/sf895/output/huggingface_asllrp_repo/SignX/detailed_prediction_20260101_131106/3381121 +视频路径: /common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4 +总关键帧数: 30 + +关键帧列表: +------------------------------------------------------------ +Gloss 0: keyframe_000_feat4_frame17_att0.618.jpg +Gloss 1: keyframe_001_feat7_frame29_att0.524.jpg +Gloss 2: keyframe_002_feat7_frame29_att0.266.jpg +Gloss 3: keyframe_003_feat8_frame32_att0.316.jpg +Gloss 4: keyframe_004_feat11_frame44_att0.486.jpg +Gloss 5: keyframe_005_feat13_frame52_att0.595.jpg +Gloss 6: keyframe_006_feat13_frame52_att0.179.jpg +Gloss 7: keyframe_007_feat17_frame67_att0.761.jpg +Gloss 8: keyframe_008_feat21_frame83_att0.176.jpg +Gloss 9: keyframe_009_feat22_frame87_att0.085.jpg +Gloss 10: keyframe_010_feat25_frame99_att0.222.jpg +Gloss 11: keyframe_011_feat28_frame110_att0.069.jpg +Gloss 12: keyframe_012_feat32_frame126_att0.146.jpg +Gloss 13: keyframe_013_feat32_frame126_att0.088.jpg +Gloss 14: keyframe_014_feat34_frame134_att0.117.jpg +Gloss 15: keyframe_015_feat32_frame126_att0.153.jpg +Gloss 16: keyframe_016_feat32_frame126_att0.090.jpg +Gloss 17: keyframe_017_feat34_frame134_att0.116.jpg +Gloss 18: keyframe_018_feat34_frame134_att0.119.jpg +Gloss 19: keyframe_019_feat34_frame134_att0.127.jpg +Gloss 20: keyframe_020_feat34_frame134_att0.128.jpg +Gloss 21: keyframe_021_feat32_frame126_att0.105.jpg +Gloss 22: keyframe_022_feat34_frame134_att0.139.jpg +Gloss 23: keyframe_023_feat34_frame134_att0.146.jpg +Gloss 24: keyframe_024_feat34_frame134_att0.149.jpg +Gloss 25: keyframe_025_feat34_frame134_att0.154.jpg +Gloss 26: keyframe_026_feat34_frame134_att0.157.jpg +Gloss 27: keyframe_027_feat34_frame134_att0.115.jpg +Gloss 28: keyframe_028_feat34_frame134_att0.161.jpg +Gloss 29: keyframe_029_feat34_frame134_att0.144.jpg diff --git a/SignX/detailed_prediction_20260101_131106/3381121/attention_weights.npy b/SignX/detailed_prediction_20260101_131106/3381121/attention_weights.npy new file mode 100644 index 0000000000000000000000000000000000000000..26dc33ea2ece45cf2af26749639e89e9d4123904 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/attention_weights.npy @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f75d778a2e7e7598b861f3b4b05e86ee83ce116f7594899cdac92ec25de5b2f2 +size 4328 diff --git a/SignX/detailed_prediction_20260101_131106/3381121/debug_video_path.txt b/SignX/detailed_prediction_20260101_131106/3381121/debug_video_path.txt new file mode 100644 index 0000000000000000000000000000000000000000..da5a2cbb36776268a619872de98f12ff9d657a6c --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/debug_video_path.txt @@ -0,0 +1,4 @@ +video_path = '/common/users/sf895/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos/3381121.mp4' +video_path type = +video_path is None: False +bool(video_path): True diff --git a/SignX/detailed_prediction_20260101_131106/3381121/feature_frame_mapping.json b/SignX/detailed_prediction_20260101_131106/3381121/feature_frame_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..3118cf5790fe3cc615abecc236ee62a0e7a9f29b --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/feature_frame_mapping.json @@ -0,0 +1,218 @@ +{ + "original_frame_count": 136, + "feature_count": 35, + "downsampling_ratio": 3.8857142857142857, + "fps": 30.0, + "mapping": [ + { + "feature_index": 0, + "frame_start": 0, + "frame_end": 3, + "frame_count": 3 + }, + { + "feature_index": 1, + "frame_start": 3, + "frame_end": 7, + "frame_count": 4 + }, + { + "feature_index": 2, + "frame_start": 7, + "frame_end": 11, + "frame_count": 4 + }, + { + "feature_index": 3, + "frame_start": 11, + "frame_end": 15, + "frame_count": 4 + }, + { + "feature_index": 4, + "frame_start": 15, + "frame_end": 19, + "frame_count": 4 + }, + { + "feature_index": 5, + "frame_start": 19, + "frame_end": 23, + "frame_count": 4 + }, + { + "feature_index": 6, + "frame_start": 23, + "frame_end": 27, + "frame_count": 4 + }, + { + "feature_index": 7, + "frame_start": 27, + "frame_end": 31, + "frame_count": 4 + }, + { + "feature_index": 8, + "frame_start": 31, + "frame_end": 34, + "frame_count": 3 + }, + { + "feature_index": 9, + "frame_start": 34, + "frame_end": 38, + "frame_count": 4 + }, + { + "feature_index": 10, + "frame_start": 38, + "frame_end": 42, + "frame_count": 4 + }, + { + "feature_index": 11, + "frame_start": 42, + "frame_end": 46, + "frame_count": 4 + }, + { + "feature_index": 12, + "frame_start": 46, + "frame_end": 50, + "frame_count": 4 + }, + { + "feature_index": 13, + "frame_start": 50, + "frame_end": 54, + "frame_count": 4 + }, + { + "feature_index": 14, + "frame_start": 54, + "frame_end": 58, + "frame_count": 4 + }, + { + "feature_index": 15, + "frame_start": 58, + "frame_end": 62, + "frame_count": 4 + }, + { + "feature_index": 16, + "frame_start": 62, + "frame_end": 66, + "frame_count": 4 + }, + { + "feature_index": 17, + "frame_start": 66, + "frame_end": 69, + "frame_count": 3 + }, + { + "feature_index": 18, + "frame_start": 69, + "frame_end": 73, + "frame_count": 4 + }, + { + "feature_index": 19, + "frame_start": 73, + "frame_end": 77, + "frame_count": 4 + }, + { + "feature_index": 20, + "frame_start": 77, + "frame_end": 81, + "frame_count": 4 + }, + { + "feature_index": 21, + "frame_start": 81, + "frame_end": 85, + "frame_count": 4 + }, + { + "feature_index": 22, + "frame_start": 85, + "frame_end": 89, + "frame_count": 4 + }, + { + "feature_index": 23, + "frame_start": 89, + "frame_end": 93, + "frame_count": 4 + }, + { + "feature_index": 24, + "frame_start": 93, + "frame_end": 97, + "frame_count": 4 + }, + { + "feature_index": 25, + "frame_start": 97, + "frame_end": 101, + "frame_count": 4 + }, + { + "feature_index": 26, + "frame_start": 101, + "frame_end": 104, + "frame_count": 3 + }, + { + "feature_index": 27, + "frame_start": 104, + "frame_end": 108, + "frame_count": 4 + }, + { + "feature_index": 28, + "frame_start": 108, + "frame_end": 112, + "frame_count": 4 + }, + { + "feature_index": 29, + "frame_start": 112, + "frame_end": 116, + "frame_count": 4 + }, + { + "feature_index": 30, + "frame_start": 116, + "frame_end": 120, + "frame_count": 4 + }, + { + "feature_index": 31, + "frame_start": 120, + "frame_end": 124, + "frame_count": 4 + }, + { + "feature_index": 32, + "frame_start": 124, + "frame_end": 128, + "frame_count": 4 + }, + { + "feature_index": 33, + "frame_start": 128, + "frame_end": 132, + "frame_count": 4 + }, + { + "feature_index": 34, + "frame_start": 132, + "frame_end": 136, + "frame_count": 4 + } + ] +} \ No newline at end of file diff --git a/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.json b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.json new file mode 100644 index 0000000000000000000000000000000000000000..cd9615ac4c89c40dbbb9b3c1817595465c463b62 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.json @@ -0,0 +1,86 @@ +{ + "translation": "BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX", + "words": [ + "BOX/ROOM", + "IX", + "NOT-YET", + "ARRIVE", + "IX", + "SHOULD", + "CONTACT", + "ns-fs-FEDEX" + ], + "total_video_frames": 35, + "frame_ranges": [ + { + "word": "BOX/ROOM", + "start_frame": 4, + "end_frame": 4, + "peak_frame": 4, + "avg_attention": 0.6183844208717346, + "confidence": "high" + }, + { + "word": "IX", + "start_frame": 7, + "end_frame": 7, + "peak_frame": 7, + "avg_attention": 0.5238878726959229, + "confidence": "high" + }, + { + "word": "NOT-YET", + "start_frame": 7, + "end_frame": 7, + "peak_frame": 7, + "avg_attention": 0.26562702655792236, + "confidence": "medium" + }, + { + "word": "ARRIVE", + "start_frame": 8, + "end_frame": 10, + "peak_frame": 8, + "avg_attention": 0.3079790771007538, + "confidence": "medium" + }, + { + "word": "IX", + "start_frame": 11, + "end_frame": 11, + "peak_frame": 11, + "avg_attention": 0.48612749576568604, + "confidence": "medium" + }, + { + "word": "SHOULD", + "start_frame": 13, + "end_frame": 13, + "peak_frame": 13, + "avg_attention": 0.5946471691131592, + "confidence": "high" + }, + { + "word": "CONTACT", + "start_frame": 13, + "end_frame": 13, + "peak_frame": 13, + "avg_attention": 0.17889028787612915, + "confidence": "low" + }, + { + "word": "ns-fs-FEDEX", + "start_frame": 17, + "end_frame": 17, + "peak_frame": 17, + "avg_attention": 0.7611479163169861, + "confidence": "high" + } + ], + "statistics": { + "avg_confidence": 0.46708640828728676, + "high_confidence_words": 4, + "medium_confidence_words": 3, + "low_confidence_words": 1 + } +} \ No newline at end of file diff --git a/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.pdf b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.pdf new file mode 100644 index 0000000000000000000000000000000000000000..63bc1ab360c829df84fe168aaab4d864d8b5e881 Binary files /dev/null and b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.pdf differ diff --git a/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.png b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.png new file mode 100644 index 0000000000000000000000000000000000000000..7cdb85e7037b4f42c5be1af8a1b3a7ad23ecfcad --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/frame_alignment.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfdc1d847461423af90dd37076d691e707d1503e670e747ef8b4574cc08dcbbc +size 143110 diff --git a/SignX/detailed_prediction_20260101_131106/3381121/gloss_to_frames.png b/SignX/detailed_prediction_20260101_131106/3381121/gloss_to_frames.png new file mode 100644 index 0000000000000000000000000000000000000000..e2c9c2c01e44bc84ff2b9ec73deb12058f13c3bd --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/gloss_to_frames.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cf9fc261023740c5cae26682718d2d53aa31ec175a64443fa1c00136e72ba61 +size 3796033 diff --git a/SignX/detailed_prediction_20260101_131106/3381121/interactive_alignment.html b/SignX/detailed_prediction_20260101_131106/3381121/interactive_alignment.html new file mode 100644 index 0000000000000000000000000000000000000000..27dc03a1aa54e2c628cdc716706df43ec28abbe5 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/interactive_alignment.html @@ -0,0 +1,579 @@ + + + + + + Interactive Word-Frame Alignment + + + +
+

🎯 Interactive Word-to-Frame Alignment Visualizer

+ +
+ Translation: BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX
+ Total Words: 8 | + Total Features: 35 +
+ +
+

⚙️ Threshold Controls

+ +
+ + + 90% +
+ + 帧的注意力权重 ≥ (峰值权重 × 阈值%) 时被认为是"显著帧" + +
+ +
+ + + 0.50 +
+ +
+ + + 0.20 +
+ + +
+ +
+

Word-to-Frame Alignment

+

+ 每个词显示为彩色矩形,宽度表示该词对应的特征帧范围。★ = 峰值帧。矩形内部显示注意力权重波形。 +

+ + +

Timeline Progress Bar

+ + +
+ Legend:

+
+ High + Medium + Low + Confidence Levels (opacity reflects confidence) +
+
+ + Peak Frame (highest attention) +
+
+ + Attention Waveform (within word region) +
+
+
+ +
+

Alignment Details

+
+
+
+ + + + diff --git a/SignX/detailed_prediction_20260101_131106/3381121/translation.txt b/SignX/detailed_prediction_20260101_131106/3381121/translation.txt new file mode 100644 index 0000000000000000000000000000000000000000..11eff905937318e113d774c75836386c4ac499a9 --- /dev/null +++ b/SignX/detailed_prediction_20260101_131106/3381121/translation.txt @@ -0,0 +1,3 @@ +With BPE: BOX/ROOM I@@ X NOT-YET ARRIVE I@@ X SHOULD CONT@@ ACT ns-fs-@@ F@@ E@@ DE@@ X +Clean: BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX +Ground Truth: BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX diff --git a/SignX/eval/attention_analysis.py b/SignX/eval/attention_analysis.py index a6185555c228c2d89b93937b6a1c8029f262c15e..7b1efa51368ac3874a9cefaeb3fc5912f9f7ff20 100644 --- a/SignX/eval/attention_analysis.py +++ b/SignX/eval/attention_analysis.py @@ -237,9 +237,12 @@ class AttentionAnalyzer: plt.tight_layout() plt.savefig(output_path, dpi=150, bbox_inches='tight') + # also save PDF copy for high-res usage + pdf_path = Path(output_path).with_suffix('.pdf') + plt.savefig(str(pdf_path), format='pdf', bbox_inches='tight') plt.close() - print(f" ✓ {output_path.name}") + print(f" ✓ {output_path.name} (PDF copy saved)") def plot_frame_alignment(self, output_path): """生成帧对齐可视化""" @@ -307,13 +310,15 @@ class AttentionAnalyzer: ax1.set_xlim(-2, self.video_frames + 2) ax1.set_ylim(-0.5, len(self.words)) - ax1.set_xlabel('Video Frame Index', fontsize=13, fontweight='bold') + # Remove redundant label (timeline info shown below) + ax1.set_xlabel('') ax1.set_ylabel('Generated Word', fontsize=13, fontweight='bold') ax1.set_title('Word-to-Frame Alignment\n(based on attention peaks, ★ = peak frame)', fontsize=15, pad=15, fontweight='bold') ax1.grid(True, alpha=0.3, axis='x', linestyle='--') ax1.set_yticks(range(len(self.words))) ax1.set_yticklabels([w['word'] for w in self.word_frame_ranges], fontsize=10) + ax1_label_pos = ax1.yaxis.label.get_position() # === 中图1: SMKD特征帧时间线进度条 === ax2 = fig.add_subplot(gs[1]) @@ -334,12 +339,14 @@ class AttentionAnalyzer: ax2.set_xlim(-2, self.video_frames + 2) ax2.set_ylim(-0.4, 0.4) - ax2.set_xlabel('SMKD Feature Frame Index', fontsize=12, fontweight='bold') + ax2.set_xlabel('') ax2.set_yticks([]) - ax2.set_title('SMKD Feature Timeline', fontsize=13, fontweight='bold') + ax2.set_title('Latent Feature Timeline', fontsize=13, fontweight='bold') ax2.grid(True, alpha=0.3, axis='x', linestyle='--') # === 中图2: 原始视频帧时间线进度条 (如果有feature mapping) === + timeline_axes = [ax2] + if feature_mapping: ax3 = fig.add_subplot(gs[2]) @@ -368,7 +375,7 @@ class AttentionAnalyzer: ax3.set_xlim(-2, original_frame_count + 2) ax3.set_ylim(-0.4, 0.4) - ax3.set_xlabel('Original Video Frame Index', fontsize=12, fontweight='bold') + ax3.set_xlabel('') ax3.set_yticks([]) ax3.set_title(f'Original Video Timeline ({original_frame_count} frames, ' f'{feature_mapping["downsampling_ratio"]:.2f}x downsampling)', @@ -376,6 +383,7 @@ class AttentionAnalyzer: ax3.grid(True, alpha=0.3, axis='x', linestyle='--') legend_row = 3 + timeline_axes.append(ax3) else: legend_row = 2 @@ -388,10 +396,23 @@ class AttentionAnalyzer: fontsize=11, transform=ax_legend.transAxes) plt.tight_layout() + fig.canvas.draw() + + # Draw shared Timeline label aligned with Generated Word label (after layout) + label_disp = ax1.transAxes.transform(ax1_label_pos) + label_fig = fig.transFigure.inverted().transform(label_disp) + timeline_bounds = [ax.get_position() for ax in timeline_axes] + timeline_center = 0.5 * (min(pos.y0 for pos in timeline_bounds) + max(pos.y1 for pos in timeline_bounds)) + fig.text(label_fig[0], timeline_center, 'Timeline', rotation='vertical', + ha='center', va='center', fontsize=12, fontweight='bold') + plt.savefig(output_path, dpi=150, bbox_inches='tight') + # Save PDF copy for high-res needs + pdf_path = Path(output_path).with_suffix('.pdf') + plt.savefig(str(pdf_path), format='pdf', bbox_inches='tight') plt.close() - print(f" ✓ {output_path.name}") + print(f" ✓ {output_path.name} (PDF copy saved)") def save_alignment_data(self, output_path): """保存帧对齐数据为JSON""" diff --git a/SignX/eval/generate_gloss_frames.py b/SignX/eval/generate_gloss_frames.py index e70cb6b5c6e61c5c49da374db1284c10f17c94bb..d3ee984c88feb0ed0c1fa7bc0096bbd4b8c87464 100644 --- a/SignX/eval/generate_gloss_frames.py +++ b/SignX/eval/generate_gloss_frames.py @@ -222,7 +222,7 @@ if __name__ == "__main__": sys.exit(1) # 处理所有样本 - sample_dirs = sorted(detailed_dir.glob("sample_*")) + sample_dirs = sorted([d for d in detailed_dir.iterdir() if d.is_dir()]) for sample_dir in sample_dirs: print(f"\n处理 {sample_dir.name}...") diff --git a/SignX/eval/regenerate_visualizations.py b/SignX/eval/regenerate_visualizations.py index 1badfcb8fdf6995ca38263b905151f0c8538485d..a9654b918140b6a7d35ba6055831d9ab261d10b4 100644 --- a/SignX/eval/regenerate_visualizations.py +++ b/SignX/eval/regenerate_visualizations.py @@ -111,10 +111,9 @@ def main(): # 处理所有样本 success_count = 0 - for sample_dir in sorted(pred_dir.glob("sample_*")): - if sample_dir.is_dir(): - if regenerate_sample_visualizations(sample_dir, video_path): - success_count += 1 + for sample_dir in sorted([d for d in pred_dir.iterdir() if d.is_dir()]): + if regenerate_sample_visualizations(sample_dir, video_path): + success_count += 1 print(f"\n✓ 完成!成功处理 {success_count} 个样本") diff --git a/SignX/eval/tiny_test_data/good_videos/171921.mp4 b/SignX/eval/tiny_test_data/good_videos/171921.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2f36631a7afa8a9b60488c1bb8b50fcc2bc40ed2 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/171921.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b55f3fae16c90ecd7e799d2515aeea9af00df4efad003d84e6b0aba1a3527822 +size 102121 diff --git a/SignX/eval/tiny_test_data/good_videos/173238.mp4 b/SignX/eval/tiny_test_data/good_videos/173238.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..09b5e9ac2639ae3ee433277bd315fba9cb8d9f45 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/173238.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48c605e2c0dbd04fe25871a7b2e270615d02a198567f3f903c3ae7da68bcf8ca +size 98921 diff --git a/SignX/eval/tiny_test_data/good_videos/173745.mp4 b/SignX/eval/tiny_test_data/good_videos/173745.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..869c78b7dd7452415e33c1a8919be909de416671 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/173745.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:289b2fa3e751823c99b78a40e38ff799dfb7e28cdc53053b045c5e9dbb15d7fb +size 494802 diff --git a/SignX/eval/tiny_test_data/good_videos/23880856.mp4 b/SignX/eval/tiny_test_data/good_videos/23880856.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..172f1227c461bc5ece5ee5f6677a9f696c6a9042 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/23880856.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:555d737baa311faa5ff33afa7d8a6ca4c3090c41e8c47eaa39569e493dce7282 +size 87354 diff --git a/SignX/eval/tiny_test_data/good_videos/23881350.mp4 b/SignX/eval/tiny_test_data/good_videos/23881350.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..1584b0a8c0ea53aa6c34ed3ac547270362c5e48e --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/23881350.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:910a66cdb56e3099362c109e0d5eca9a802d84384447450361a17fd1eadd2437 +size 956456 diff --git a/SignX/eval/tiny_test_data/good_videos/31655975.mp4 b/SignX/eval/tiny_test_data/good_videos/31655975.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..ef5900e88413151ac543be8ca84b28e1eb12dff8 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/31655975.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:be37c2b598e44b89f31c5f716b8e58953f222b1da7e5d78043a7bdf33df9747a +size 632842 diff --git a/SignX/eval/tiny_test_data/good_videos/31657848.mp4 b/SignX/eval/tiny_test_data/good_videos/31657848.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b66c644eaf2ed2ea941ec161aa7d0384f54c6f86 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/31657848.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7959393ce0fb59a832113b12966203777bef8859c4f21b9b4401b5621f5bb80 +size 79933 diff --git a/SignX/eval/tiny_test_data/good_videos/3378265.mp4 b/SignX/eval/tiny_test_data/good_videos/3378265.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f3d543bb629ed7325730f3a4af75444f7cacacde --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/3378265.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e91b2fbe52346403e109933052e53dcf3e172b6a638ccc87eb72507d2ab0ba3 +size 739857 diff --git a/SignX/eval/tiny_test_data/good_videos/3381121.mp4 b/SignX/eval/tiny_test_data/good_videos/3381121.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..2e45ddfa8af468fd40e80b2b5d8596a032eb575b --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/3381121.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:571fea555cf82d20e3ccb155759389414f2e214b9a5aa82b08a022a47395adca +size 923026 diff --git a/SignX/eval/tiny_test_data/good_videos/4235359.mp4 b/SignX/eval/tiny_test_data/good_videos/4235359.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..93dc226e40b5d526f70e48e940636187412c0dbc --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/4235359.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3255cd64085e24f93527adc5159b457583c2da9dfcc21472e370254c6f3b0812 +size 62516 diff --git a/SignX/eval/tiny_test_data/good_videos/4236171.mp4 b/SignX/eval/tiny_test_data/good_videos/4236171.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..58c88658e2991554b5db7b56e8e55ee140d05d1e --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/4236171.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:608e2c41f8c445ecbf08bc22321c7e50c69999108755d9a4d2c4d784dbc20dc8 +size 529850 diff --git a/SignX/eval/tiny_test_data/good_videos/50802118.mp4 b/SignX/eval/tiny_test_data/good_videos/50802118.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..58d8c78e1be5b6088659bf0d68abbe4b0427ab7b --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/50802118.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c3db765ef374d1247d8d4a90ec00a01833fda7d71c171ec774e675b092674a9 +size 90142 diff --git a/SignX/eval/tiny_test_data/good_videos/5597316.mp4 b/SignX/eval/tiny_test_data/good_videos/5597316.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..51495c6314fba3b5342f7d7fd24dbab1ebde6dff --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/5597316.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a40b162f904048599a7b3ce04d439038afcc8f8c8a70bcd15c6faae00ad495c0 +size 88439 diff --git a/SignX/eval/tiny_test_data/good_videos/6185086.mp4 b/SignX/eval/tiny_test_data/good_videos/6185086.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..18f7847ef09c26292f614ccb90abf64fba5fd1e2 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/6185086.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea4e7811e3452b5c4a36ef84aa1bad600af68b5b5d2a29f130a42907a27f29c3 +size 724598 diff --git a/SignX/eval/tiny_test_data/good_videos/6185381.mp4 b/SignX/eval/tiny_test_data/good_videos/6185381.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..6ea2738a1283d33036f3a3ab0aab3a0ca8ea78aa --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/6185381.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c35bdbf4087677ffb0b9d348feda0d5f45f53549f7cc6c3e8680303a6562b3b5 +size 632143 diff --git a/SignX/eval/tiny_test_data/good_videos/619048.mp4 b/SignX/eval/tiny_test_data/good_videos/619048.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..355e2e9bedc67d1b0dca11ff9ce8155554e457c4 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/619048.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:011b44c741b104d2aa07efb0df33df970e1ece034a7915590c68a9716d843f52 +size 135468 diff --git a/SignX/eval/tiny_test_data/good_videos/629983.mp4 b/SignX/eval/tiny_test_data/good_videos/629983.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b5b5822e51752254f993648b9f7a448a3d261b1e --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/629983.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bb7fd93838b5c931ac89f00adf62c08be3e45f0b90803126035c924bb7e2bde +size 90085 diff --git a/SignX/eval/tiny_test_data/good_videos/634818.mp4 b/SignX/eval/tiny_test_data/good_videos/634818.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..04a4494b97b11650a4606fa47de1a5506b96b169 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/634818.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a7d034c6da97babb440de4eb8dc598e243141a9a8ed3b9ca3b6b222841eea6d +size 523852 diff --git a/SignX/eval/tiny_test_data/good_videos/63579.mp4 b/SignX/eval/tiny_test_data/good_videos/63579.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..da8d8cd4cbfa9fb0366708cd9517b9e9068e2912 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/63579.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:21c8fa94f8c3bc8f9a771ed47b646ecc2e02c0345bedf37ea3b803e9d9d8293c +size 52159 diff --git a/SignX/eval/tiny_test_data/good_videos/7454155.mp4 b/SignX/eval/tiny_test_data/good_videos/7454155.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..30ba2a974f54c831c65a32ef2fbb7d794ae92f4d --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7454155.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb47173044695c44654232f7fed41810e08f999280d066a84c88c83cdc3b9221 +size 66481 diff --git a/SignX/eval/tiny_test_data/good_videos/7566726.mp4 b/SignX/eval/tiny_test_data/good_videos/7566726.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..63fcecb2f4eea77a5965cea870d502a669317e3a --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7566726.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79376e879cd691efe05a10db610d97c3a06d33f3d44dafedeaddabb1a00cdfef +size 54623 diff --git a/SignX/eval/tiny_test_data/good_videos/7569669.mp4 b/SignX/eval/tiny_test_data/good_videos/7569669.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..f6974c051886db2204fd2c7a66fe1e70136ef007 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7569669.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e756f0fcb4bfa4a64f433dc11309a4752fa202884310c72f5deb64923e10d5a4 +size 80089 diff --git a/SignX/eval/tiny_test_data/good_videos/7701925.mp4 b/SignX/eval/tiny_test_data/good_videos/7701925.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c5ba39750ec71d49688081410fb636fee62de979 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7701925.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2508adc6e401bcf01be6b1d3599bb047db0c5c90b26199bb9bfa32f49d17f52a +size 88745 diff --git a/SignX/eval/tiny_test_data/good_videos/7710510.mp4 b/SignX/eval/tiny_test_data/good_videos/7710510.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..784843c024f80798ac02cdddf24c517f5c0e7104 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7710510.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6307afb97fa84097c574ded2cbae7083e6bf45493e5c9683fc5fe78aba29cf54 +size 109316 diff --git a/SignX/eval/tiny_test_data/good_videos/7981884.mp4 b/SignX/eval/tiny_test_data/good_videos/7981884.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..033a94b30bdb57ce59afb193600c50fb4843571b --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7981884.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:35b84894607a914e677d35b22b977a06a20018398381b9af514c1e551b608057 +size 690566 diff --git a/SignX/eval/tiny_test_data/good_videos/7982378.mp4 b/SignX/eval/tiny_test_data/good_videos/7982378.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..a4773c2b85fa0e56af21105b5767dd0204481886 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7982378.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:112e37f2307ba072084e9b56519b68555a4affbf3543ca6fe71ae2151e54d5ac +size 755230 diff --git a/SignX/eval/tiny_test_data/good_videos/7983362.mp4 b/SignX/eval/tiny_test_data/good_videos/7983362.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..b5769abbbdfc733e13d5ed2f72342334b11bc40f --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/7983362.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64341d796bd95627ef2d141fbc36bf025778461dc8670cf39b3c358ddf5be036 +size 109429 diff --git a/SignX/eval/tiny_test_data/good_videos/83940254.mp4 b/SignX/eval/tiny_test_data/good_videos/83940254.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..beea3c9fc5851c023a414eab2289c97dd844ab9e --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/83940254.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e821e90296446a5ef9b2013f636cdf95d1782e01f3420653c40b024e53513614 +size 86808 diff --git a/SignX/eval/tiny_test_data/good_videos/83940846.mp4 b/SignX/eval/tiny_test_data/good_videos/83940846.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..213eb44ced60d414324fb60a63878895d84078fe --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/83940846.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f5d5a2d3e345ed478ac34f60e1dd25e2affdc8eaf021a00d98df5a1559fa068e +size 64648 diff --git a/SignX/eval/tiny_test_data/good_videos/83941734.mp4 b/SignX/eval/tiny_test_data/good_videos/83941734.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..03f628ed7449dfd04fb0d7a1b08f3b7111051dae --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/83941734.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e74082b54128ed094006d64034886f14ec9be2247525ad59d44f27f9bbd58897 +size 786211 diff --git a/SignX/eval/tiny_test_data/good_videos/8394388.mp4 b/SignX/eval/tiny_test_data/good_videos/8394388.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..be5eb12594858afce030d54cf64f9a73a3c722dd --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/8394388.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0338d7524771d4709d0e34efa92e653afb80b8c9480fbdd16b525067bb265f06 +size 646955 diff --git a/SignX/eval/tiny_test_data/good_videos/842226.mp4 b/SignX/eval/tiny_test_data/good_videos/842226.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..428f6a27e83029d15683451e32dd9ebd1c8b3861 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/842226.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:272f1c956cbf0775d4cc488b5f2cb0b0507c4cafba8c6ded23844c7862476d4d +size 90028 diff --git a/SignX/eval/tiny_test_data/good_videos/843240.mp4 b/SignX/eval/tiny_test_data/good_videos/843240.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..83bf1459bbe6fecc5bd6e4305bf75423391355d6 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/843240.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d0de9db68b470cad0d3de0e84c8d7009a99686d1ce8b948df11b8648b6f133ed +size 84340 diff --git a/SignX/eval/tiny_test_data/good_videos/97999512.mp4 b/SignX/eval/tiny_test_data/good_videos/97999512.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..c7796925ca994a4382fd54d4998d3887f59ff265 --- /dev/null +++ b/SignX/eval/tiny_test_data/good_videos/97999512.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:36c4ebf19463ae769432d561a0ed2d187bbd62f74c478faf06f23f0419444722 +size 58378 diff --git a/SignX/good_videos_copy.sh b/SignX/good_videos_copy.sh new file mode 100644 index 0000000000000000000000000000000000000000..89e7dba89b4569db14d0097fddd1f5109feaba20 --- /dev/null +++ b/SignX/good_videos_copy.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# 执行前请确保目标目录可写:SignX/eval/tiny_test_data/good_videos +set -e + +DEST="/research/cbim/vast/sf895/code/Sign-X/output/huggingface_asllrp_repo/SignX/eval/tiny_test_data/good_videos" +SRC_BASE="/research/cbim/vast/sf895/code/Sign-X/output/huggingface_asllrp_repo/ASLLRP_utterances_results" + +mkdir -p "$DEST" + +cp "$SRC_BASE/7710510/crop_original_video.mp4" "$DEST/7710510.mp4" +cp "$SRC_BASE/97999512/crop_original_video.mp4" "$DEST/97999512.mp4" +cp "$SRC_BASE/7566726/crop_original_video.mp4" "$DEST/7566726.mp4" +cp "$SRC_BASE/629983/crop_original_video.mp4" "$DEST/629983.mp4" +cp "$SRC_BASE/619048/crop_original_video.mp4" "$DEST/619048.mp4" +cp "$SRC_BASE/171921/crop_original_video.mp4" "$DEST/171921.mp4" +cp "$SRC_BASE/6185381/crop_original_video.mp4" "$DEST/6185381.mp4" +cp "$SRC_BASE/83940846/crop_original_video.mp4" "$DEST/83940846.mp4" +cp "$SRC_BASE/63579/crop_original_video.mp4" "$DEST/63579.mp4" +cp "$SRC_BASE/83940254/crop_original_video.mp4" "$DEST/83940254.mp4" +cp "$SRC_BASE/6185086/crop_original_video.mp4" "$DEST/6185086.mp4" +cp "$SRC_BASE/83941734/crop_original_video.mp4" "$DEST/83941734.mp4" +cp "$SRC_BASE/7982378/crop_original_video.mp4" "$DEST/7982378.mp4" +cp "$SRC_BASE/31655975/crop_original_video.mp4" "$DEST/31655975.mp4" +cp "$SRC_BASE/7454155/crop_original_video.mp4" "$DEST/7454155.mp4" +cp "$SRC_BASE/3381121/crop_original_video.mp4" "$DEST/3381121.mp4" +cp "$SRC_BASE/23880856/crop_original_video.mp4" "$DEST/23880856.mp4" +cp "$SRC_BASE/3378265/crop_original_video.mp4" "$DEST/3378265.mp4" +cp "$SRC_BASE/7701925/crop_original_video.mp4" "$DEST/7701925.mp4" +cp "$SRC_BASE/4236171/crop_original_video.mp4" "$DEST/4236171.mp4" +cp "$SRC_BASE/8394388/crop_original_video.mp4" "$DEST/8394388.mp4" +cp "$SRC_BASE/634818/crop_original_video.mp4" "$DEST/634818.mp4" +cp "$SRC_BASE/173745/crop_original_video.mp4" "$DEST/173745.mp4" +cp "$SRC_BASE/7569669/crop_original_video.mp4" "$DEST/7569669.mp4" +cp "$SRC_BASE/50802118/crop_original_video.mp4" "$DEST/50802118.mp4" +cp "$SRC_BASE/4235359/crop_original_video.mp4" "$DEST/4235359.mp4" +cp "$SRC_BASE/842226/crop_original_video.mp4" "$DEST/842226.mp4" +cp "$SRC_BASE/7981884/crop_original_video.mp4" "$DEST/7981884.mp4" +cp "$SRC_BASE/31657848/crop_original_video.mp4" "$DEST/31657848.mp4" +cp "$SRC_BASE/7983362/crop_original_video.mp4" "$DEST/7983362.mp4" +cp "$SRC_BASE/5597316/crop_original_video.mp4" "$DEST/5597316.mp4" +cp "$SRC_BASE/173238/crop_original_video.mp4" "$DEST/173238.mp4" +cp "$SRC_BASE/843240/crop_original_video.mp4" "$DEST/843240.mp4" +cp "$SRC_BASE/23881350/crop_original_video.mp4" "$DEST/23881350.mp4" + + + + - Sample 4 (7710510): NIGHT IX FATHER ARRIVE fs-LATE + - Sample 7 (97999512): #NO IX-1p NOT GO-OUT + - Sample 11 (7566726): MAYBE POSS CAR HERE + - Sample 15 (629983): IX FINISH WORK WHEN IX + - Sample 26 (619048): IF STUDENT IX HEAR/LISTEN TEACH+AGENT FUTURE LEARN SOMETHING/ONE + - Sample 33 (171921): IX-1p NOT LIKE PINEAPPLE fs-CREAM+CHEESE IX-1p + - Sample 38 (6185381): MOTHER SICK HOW part:indef + - Sample 40 (83940846, 83940945): DEPART WHO + - Sample 43 (63579): IX-1p WORK + - Sample 45 (83940254): SWIM fs-BEACH IX WHO IX + - Sample 53 (6185086): WHO MUST PAY EVERY-MONTH/RENT + - Sample 58 (83941734, 83943314): FRIEND IX DEPART CAMP + - Sample 61 (7982378): IX-1p PROCEED TAKE-UP #BBQ GROUP/TOGETHER + - Sample 64 (31655975): IX-1p SCL:U-L"person passed out" DRUNK + PAST+NIGHT QMwg + - Sample 68 (7454155, 8397543): BUY CAR WHO part:indef + - Sample 74 (3381121): BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT + ns-fs-FEDEX + - Sample 81 (23880856): #IF RAIN IX-1p DEPART part:indef + - Sample 86 (3378265): #IF IX NOT BORE IX-1p FUTURE READ IX-1p + part:indef + - Sample 87 (7701925, 7709712): IX-1p GO-OUT SWIM fs-BEACH + - Sample 92 (4236171, 61835108): FRIEND WANT BUY PLAID VOLUNTEER/SHIRT + - Sample 94 (8394388): FRIEND GO-OUT TOGETHER/GO-STEADY + - Sample 107 (634818): FRIEND IX-pl PARTY GOOD/THANK-YOU + - Sample 118 (173745, 173746, 26827222): CAR BREAK-DOWN + - Sample 133 (7569669): POSS-1p FRIEND TELL IX BORN ns-CHICAGO + - Sample 150 (50802118): IX ns-fs-JOHN HAVE DIFFERENT CAR + - Sample 167 (4235359): WHO ASK FOR DIRECT + - Sample 172 (842226): FRIEND LOVE SURF-INTERNET REALLY+WORK QMwg + - Sample 179 (7981884): IX TEND CHAT WITH IX-pl-2 + - Sample 184 (31657848): MOTHER SICK QMwg + - Sample 187 (7983362): FATHER FINISH MOW GRASS + - Sample 192 (5597316): SOMETHING/ONE BUY CAR WHO part:indef + - Sample 199 (173238): #NO IX-1p USE CORRECT KEY + - Sample 206 (843240): #HS IX GO-OUT WHERE IX + - Sample 208 (23881350): HAPPEN RAIN IX-1p STAY HOME + + +echo "复制完成:34 个视频" +echo "如需额外的同义 key,可将上面命令中的目录替换为 83940945、83943314、7709712、61835108、173746、26827222、8397543 等再运行一次。" diff --git a/SignX/inference.sh b/SignX/inference.sh index 29d02521d33adf67cbe62667ba2fa31ede994441..df55929dac270fec68cbfe4019d46020500032e5 100644 --- a/SignX/inference.sh +++ b/SignX/inference.sh @@ -282,7 +282,8 @@ if [ -f "$TEMP_DIR/prediction.txt" ]; then ATTENTION_ANALYSIS_DIR="$dest_path" # 统计样本数量 - sample_count=$(find "$dest_path" -maxdepth 1 -type d -name "sample_*" | wc -l) + mapfile -t SAMPLE_DIRS < <(find "$dest_path" -mindepth 1 -maxdepth 1 -type d -print | sort) + sample_count=${#SAMPLE_DIRS[@]} echo " ✓ 已保存 $sample_count 个样本的详细分析到: $dest_path" # 步骤1:生成特征-帧映射 (Feature-to-Frame Mapping) @@ -291,11 +292,15 @@ if [ -f "$TEMP_DIR/prediction.txt" ]; then if [ -f "$SCRIPT_DIR/eval/generate_feature_mapping.py" ]; then # 切换到 signx-slt 环境 (有 cv2) conda activate signx-slt - for sample_dir in "$dest_path"/sample_*; do - if [ -d "$sample_dir" ]; then - python "$SCRIPT_DIR/eval/generate_feature_mapping.py" "$sample_dir" "$VIDEO_PATH" 2>&1 | grep -E "(特征数量|原始帧数|已生成映射|错误)" - fi - done + if [ ${#SAMPLE_DIRS[@]} -eq 0 ]; then + echo " ⚠ 未找到样本目录,跳过特征映射生成" + else + for sample_dir in "${SAMPLE_DIRS[@]}"; do + if [ -d "$sample_dir" ]; then + python "$SCRIPT_DIR/eval/generate_feature_mapping.py" "$sample_dir" "$VIDEO_PATH" 2>&1 | grep -E "(特征数量|原始帧数|已生成映射|错误)" + fi + done + fi else echo " ⓘ generate_feature_mapping.py 未找到,跳过特征映射生成" fi @@ -305,7 +310,11 @@ if [ -f "$TEMP_DIR/prediction.txt" ]; then echo -e "${BLUE}重新生成可视化(使用最新代码)...${NC}" if [ -f "$SCRIPT_DIR/eval/regenerate_visualizations.py" ]; then # 已在 signx-slt 环境 - python "$SCRIPT_DIR/eval/regenerate_visualizations.py" "$dest_path" "$VIDEO_PATH" + if [ ${#SAMPLE_DIRS[@]} -eq 0 ]; then + echo " ⚠ 未找到样本目录,跳过可视化生成" + else + python "$SCRIPT_DIR/eval/regenerate_visualizations.py" "$dest_path" "$VIDEO_PATH" + fi else echo " ⓘ regenerate_visualizations.py 未找到,使用旧版本" if [ -f "$SCRIPT_DIR/eval/generate_gloss_frames.py" ]; then @@ -318,11 +327,15 @@ if [ -f "$TEMP_DIR/prediction.txt" ]; then echo -e "${BLUE}生成交互式HTML可视化...${NC}" if [ -f "$SCRIPT_DIR/eval/generate_interactive_alignment.py" ]; then # 处理所有样本 - for sample_dir in "$dest_path"/sample_*; do - if [ -d "$sample_dir" ]; then - python "$SCRIPT_DIR/eval/generate_interactive_alignment.py" "$sample_dir" - fi - done + if [ ${#SAMPLE_DIRS[@]} -eq 0 ]; then + echo " ⚠ 未找到样本目录,跳过交互式HTML生成" + else + for sample_dir in "${SAMPLE_DIRS[@]}"; do + if [ -d "$sample_dir" ]; then + python "$SCRIPT_DIR/eval/generate_interactive_alignment.py" "$sample_dir" + fi + done + fi else echo " ⓘ generate_interactive_alignment.py 未找到,跳过交互式HTML生成" fi @@ -332,12 +345,16 @@ if [ -f "$TEMP_DIR/prediction.txt" ]; then echo -e "${BLUE}提取关键帧并叠加注意力可视化...${NC}" if [ -f "$SCRIPT_DIR/eval/extract_attention_keyframes.py" ]; then # 处理所有样本 - for sample_dir in "$dest_path"/sample_*; do - if [ -d "$sample_dir" ]; then - echo " 处理样本: $(basename "$sample_dir")" - python "$SCRIPT_DIR/eval/extract_attention_keyframes.py" "$sample_dir" "$VIDEO_PATH" - fi - done + if [ ${#SAMPLE_DIRS[@]} -eq 0 ]; then + echo " ⚠ 未找到样本目录,跳过关键帧提取" + else + for sample_dir in "${SAMPLE_DIRS[@]}"; do + if [ -d "$sample_dir" ]; then + echo " 处理样本: $(basename "$sample_dir")" + python "$SCRIPT_DIR/eval/extract_attention_keyframes.py" "$sample_dir" "$VIDEO_PATH" + fi + done + fi else echo " ⓘ extract_attention_keyframes.py 未找到,跳过关键帧提取" fi diff --git a/SignX/inference_output.txt b/SignX/inference_output.txt index c56ee188fd443f51ac38d0dc0b251f5ace009a9a..a37aeb38b8d5eeef3f7cc31d5bf0b4428e929c16 100644 --- a/SignX/inference_output.txt +++ b/SignX/inference_output.txt @@ -1 +1 @@ -#IF FRIEND GROUP/TOGE@@ TH@@ E@@ R DEPART PARTY IX-1p JO@@ I@@ N IX-1p +BOX/ROOM I@@ X NOT-YET ARRIVE I@@ X SHOULD CONT@@ ACT ns-fs-@@ F@@ E@@ DE@@ X diff --git a/SignX/inference_output.txt.clean b/SignX/inference_output.txt.clean index 73936a2c533f7a882dcbfdd6228eb27b96674f0d..170e869182df02450b0fc9037b3a8ada0d90d22b 100644 --- a/SignX/inference_output.txt.clean +++ b/SignX/inference_output.txt.clean @@ -1 +1 @@ -#IF FRIEND GROUP/TOGETHER DEPART PARTY IX-1p JOIN IX-1p +BOX/ROOM IX NOT-YET ARRIVE IX SHOULD CONTACT ns-fs-FEDEX diff --git a/SignX/models/evalu.py b/SignX/models/evalu.py index 015f178e61762120da9b3ad5e81ac01cf863a71e..3efb3c01060508e3489ef31a9d33629be8153818 100644 --- a/SignX/models/evalu.py +++ b/SignX/models/evalu.py @@ -5,10 +5,12 @@ from __future__ import division from __future__ import print_function import time +import re import numpy as np import tensorflow as tf from utils import queuer, util, metric +from pathlib import Path def strip_leading_index_tokens(tokens): @@ -57,6 +59,65 @@ def _flatten_attention_batches(attention_batches): return flattened +def _load_gloss_mapping(): + """Lazy-load ASLLRP gloss mapping (video_id -> text).""" + cache = getattr(_load_gloss_mapping, "_cache", None) + if cache is not None: + return cache + + candidate_paths = [ + Path(__file__).resolve().parent.parent / "../ASLLRP_utterances_mapping.txt", + Path(__file__).resolve().parent.parent / "ASLLRP_utterances_mapping.txt", + Path(__file__).resolve().parent.parent / "output/ASLLRP_utterances_mapping.txt", + Path(__file__).resolve().parent.parent / "../output/ASLLRP_utterances_mapping.txt", + ] + + mapping = {} + for cand in candidate_paths: + cand = cand.resolve() + if not cand.exists(): + continue + try: + with cand.open('r', encoding='utf-8') as f: + for line in f: + line = line.strip() + if not line or ':' not in line: + continue + key, text = line.split(':', 1) + mapping[key.strip()] = text.strip() + tf.logging.info(f"[GT] Loaded gloss mapping from {cand}") + break + except Exception as exc: + tf.logging.warning(f"[GT] Failed to load mapping from {cand}: {exc}") + mapping = {} + + _load_gloss_mapping._cache = mapping if mapping else None + return _load_gloss_mapping._cache + + +def _lookup_ground_truth_text(video_path): + """Return GT gloss string for the given video path if available.""" + if not video_path: + return None + mapping = _load_gloss_mapping() + if not mapping: + return None + + stem = Path(video_path).stem + candidates = [stem] + if '_' in stem: + candidates.append(stem.split('_')[0]) + + for candidate in candidates: + if candidate in mapping: + return mapping[candidate] + # also try stripping leading zeros + stripped = candidate.lstrip('0') + if stripped and stripped in mapping: + return mapping[stripped] + return None + + def decode_target_token(id_seq, vocab): """Convert sequence ids into tokens""" valid_id_seq = [] @@ -574,6 +635,7 @@ def dump_detailed_attention_output(tranes, output, indices, attentions, video_pa """ import os import sys + import re from datetime import datetime from pathlib import Path @@ -605,6 +667,21 @@ def dump_detailed_attention_output(tranes, output, indices, attentions, video_pa tf.logging.info(f"[DEBUG] Found {len(flattened_attn)} valid attention samples") + # If只推理单个视频,使用文件名作为样本目录,便于定位 + video_based_name = None + if video_path: + try: + candidate = Path(video_path).stem + if candidate: + sanitized = re.sub(r'[^0-9A-Za-z._-]+', '_', candidate).strip('_') + if sanitized: + video_based_name = sanitized + except Exception as exc: + tf.logging.warning(f"Failed to derive video-based sample name: {exc}") + + use_video_name = video_based_name is not None and len(flattened_attn) == 1 + gt_text = _lookup_ground_truth_text(video_path) if video_path else None + for sample_idx, sample_attn in enumerate(flattened_attn): if sample_idx >= len(tranes): break @@ -621,8 +698,12 @@ def dump_detailed_attention_output(tranes, output, indices, attentions, video_pa trans = ' '.join(trans) trans_clean = trans.replace('@@ ', '') - # 创建样本专属目录 - sample_dir = detail_dir / f"sample_{sample_idx:03d}" + # 创建样本专属目录(单视频推理时用文件名,更易记忆) + if use_video_name and sample_idx == 0: + sample_name = video_based_name + else: + sample_name = f"sample_{sample_idx:03d}" + sample_dir = detail_dir / sample_name sample_dir.mkdir(exist_ok=True) # 保存numpy数据 @@ -632,6 +713,10 @@ def dump_detailed_attention_output(tranes, output, indices, attentions, video_pa with open(sample_dir / "translation.txt", 'w', encoding='utf-8') as f: f.write(f"With BPE: {trans}\n") f.write(f"Clean: {trans_clean}\n") + if gt_text: + f.write(f"Ground Truth: {gt_text}\n") + else: + f.write("Ground Truth: [NOT FOUND]\n") # Calculate and save feature-to-frame mapping if video_path and os.path.exists(video_path):