fix: EasyOCR inner timeout mismatch + fresh timestamp gate放宽
1. EasyOCR inner timeout 30s→_OCR_TIMEOUT-1(9s) 外层join 10s,inner必须<外层,否则线程永远alive跳过 2. _ocr_text_has_fresh_timestamp: 时间戳全过期但含新鲜内容特征时放行 旧时间戳后紧跟新消息(无独立时间戳)不再被整批丢弃
This commit is contained in:
+13
-5
@@ -1350,8 +1350,10 @@ class MessageMonitor:
|
||||
return
|
||||
# EasyOCR 用原图(1x):2x 图送 GPU 显存压力大 + 加速泄漏
|
||||
img_np = _np.array(im_original)
|
||||
# ⚠ 超时不能太短:首次加载模型 3-10s + 图片处理,10s 必超时
|
||||
text = self._call_easyocr_safe(img_np, timeout=30)
|
||||
# inner timeout 必须 < 外层 _OCR_TIMEOUT (10s),
|
||||
# 否则线程永远在外层 join 超时前不会结束 → 永远 "线程存活,跳过"。
|
||||
_inner_timeout = max(_OCR_TIMEOUT - 1, 1)
|
||||
text = self._call_easyocr_safe(img_np, timeout=_inner_timeout)
|
||||
if text:
|
||||
easy_text[0] = text
|
||||
|
||||
@@ -2879,11 +2881,12 @@ class MessageMonitor:
|
||||
return False
|
||||
|
||||
def _ocr_text_has_fresh_timestamp(self, text: str) -> bool:
|
||||
"""检查 OCR 文本中的时间戳是否新鲜。
|
||||
"""检查 OCR 文本是否可能包含新消息。
|
||||
|
||||
有时间戳且至少一个 ≤300s → True(新消息)
|
||||
有时间戳但全部过期 → False(历史消息)
|
||||
有时间戳且至少一个 ≤300s → True(确定新消息)
|
||||
无时间戳 → 保守放行(可能是短句无时间戳的新消息)
|
||||
有时间戳但全部过期 → 检查文本是否含新鲜内容特征(疑问词/问句等),
|
||||
若含则放行(新消息可能没有独立时间戳),否则丢弃
|
||||
"""
|
||||
if not text:
|
||||
return False
|
||||
@@ -2898,6 +2901,11 @@ class MessageMonitor:
|
||||
return True
|
||||
except Exception:
|
||||
pass
|
||||
# 所有时间戳都过期,但文本含新鲜内容特征 → 可能是旧时间戳后紧跟新消息
|
||||
# 让 stage splitting 的逐条放行逻辑做精细过滤
|
||||
if self._looks_fresh_content(text):
|
||||
logger.debug(f"[ocr] 时间戳全过期但含新鲜特征,放行: {text[:80]!r}")
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user