From 65c77452c28d111f3766cf53cb30365b8e17d9a8 Mon Sep 17 00:00:00 2001 From: Admin Date: Fri, 17 Jul 2026 12:26:31 +0000 Subject: [PATCH] debug: show raw indices and fix boundary check --- internal/captcha/handler.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/captcha/handler.go b/internal/captcha/handler.go index 134a7f8..f68bbc5 100644 --- a/internal/captcha/handler.go +++ b/internal/captcha/handler.go @@ -439,17 +439,22 @@ func decodeMathFromOutput(output []float32) string { allChars[t] = maxIdx } - // 打印所有位置的识别结果 + // 打印所有位置的识别结果(包括索引值) debugStr := "DEBUG argmax: " for _, idx := range allChars { if idx > 0 && idx <= len(CHARS) { - debugStr += string(CHARS[idx-1]) - } else { + debugStr += fmt.Sprintf("%c", CHARS[idx-1]) + } else if idx == 0 { debugStr += "_" + } else { + debugStr += fmt.Sprintf("[%d]", idx) // 显示越界索引 } } fmt.Println(debugStr) + // 打印原始索引值 + fmt.Printf("DEBUG raw indices: %v\n", allChars[:20]) + // CTC 解码: 跳过 blank (index 0) 和连续重复 result := "" lastIdx := -1