ry-ocr/ (新)
本地发票识别微服务 (PaddleOCR 3.x + FastAPI, 8801)
- QR 优先: 扫到二维码即取开票时间/发票号/金额; 没扫到/格式不合法直接判非发票, 不跑 OCR
- 配置 QR_FULL_OCR 控制快路径(false, 0.2s)还是全字段(true, 4.5s)
- /recognize/invoice (multipart) + /recognize/invoice/by-path (本地路径, 白名单) + /recognize/text
- is_invoice / from_qr / qr_raw / qr_error / error_code 字段
- 12 字段发票抽取 (regex + 启发式, 左右主体识别)
- 超时保护 (15s 单页 / 60s 总流程) + PaddleOCR 单例 + ThreadPoolExecutor
ry-api/ruoyi-business/
- pom.xml: 加 hutool-http/json/core 5.8.27, lombok 1.18.30 (OcrClient @Slf4j 所需)
- ocr/: OcrClient + InvoiceResult/Fields/Line + ZipExtractor + InvoiceOcrScheduler
- oss/: OssUploader + OssConfMeta (OCR 识别后重传 OSS)
- config/: OcrConfig + OcrExecutorConfig (后台线程池)
- service/impl/InvoiceOcrService: 后台提交 OCR, ZIP 路径解压识别, 替换场景先清旧
- 会议材料 CRUD 全套 (BizMeetingAuditLog/Executor/Invoice/Material/Supervisor):
controller + service + mapper + domain + xml
ry-vue3/
- MeetingDetail.vue (新建): 会议详情页 (含评分维度章节, 改只读)
- Meetings.vue / OssFileUploader.vue / router / Login.vue: 适配新字段
ry-api/ruoyi-admin/
- RuoYiApplication.java + application.yml: 启用 @Async 异步支持
_self/
- manager_meetings.md / manager_meeting_detail.md: 文档
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""基准测试:模型预热后,统计 PNG / PDF 单次识别耗时"""
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
try:
|
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
except Exception:
|
|
pass
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
sys.path.insert(0, str(ROOT))
|
|
|
|
from app.core import warmup
|
|
from app.services.recognize_service import recognize_file
|
|
|
|
|
|
def bench(label: str, file_path: Path, runs: int = 5):
|
|
content = file_path.read_bytes()
|
|
print(f"\n=== {label}: {file_path.name} ({len(content)} bytes) ===")
|
|
|
|
# 预热(不计耗时) - 现在 warmup 会真跑一次 dummy 图预测
|
|
print("预热中(不计入)...", flush=True)
|
|
warmup()
|
|
print("预热完成", flush=True)
|
|
|
|
times = []
|
|
for i in range(runs):
|
|
t0 = time.time()
|
|
result = recognize_file(file_path.name, content)
|
|
elapsed = (time.time() - t0) * 1000
|
|
times.append(elapsed)
|
|
print(f" 第 {i+1} 次: {elapsed:7.1f} ms success={result.success}")
|
|
|
|
times.sort()
|
|
print(f"\n min: {times[0]:7.1f} ms")
|
|
print(f" median: {times[len(times)//2]:7.1f} ms")
|
|
print(f" max: {times[-1]:7.1f} ms")
|
|
print(f" avg: {sum(times)/len(times):7.1f} ms")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
bench("PNG", ROOT / "fapiao_1.png", runs=5)
|
|
bench("PDF", ROOT / "fapiao.pdf", runs=5) |