90fe705e8f
- 核心变更: - app/services/layout_detector.py: 重写布局检测器,从 PicoDet-S_layout_3cls 迁移到 DocLayout-YOLO (DocStructBench, imgsz=1024) - 支持多设备推理 (CPU/CUDA/DirectML/OpenVINO 等),自动探测最优设备 - 预处理改为 letterbox (保比例缩放+灰边 padding),坐标还原使用 (model_coord - padding) / ratio 公式 - 后处理解析 YOLOv10 end-to-end 输出 [N,6]=[x1,y1,x2,y2,conf,cls] - 类别映射改为按 class name 动态匹配 (figure/figure_group→picture, table/table_group→table) - 新增文件: - scripts/export_doclayout_yolo_onnx.py: DocLayout-YOLO ONNX 导出脚本 (独立 venv 运行) - tests/test_layout_detector.py: 布局检测器完整测试 (35 个用例) - 配置更新: - .env.example: 更新布局检测配置 (新增 LAYOUT_IMGSZ, LAYOUT_DEVICE, LAYOUT_DEVICE_ID) - app/config.py: Settings 类对应字段 - pyproject.toml: 新增 export 依赖组 (torch, doclayout-yolo, onnx 等) - 删除旧文件: - scripts/export_picodet_onnx.py: 旧 PicoDet 导出脚本 - 文档更新: - README.md: 更新环境变量说明 - 相关服务注释更新 (pdf_image_extractor.py, summary_persister.py, reextract_images.py) 此重构遵循项目初期开发阶段规范,大胆调整数据模型,无需向后兼容。
66 lines
2.6 KiB
Bash
66 lines
2.6 KiB
Bash
# ─── 应用 ────────────────────────────────
|
||
APP_HOST=127.0.0.1
|
||
APP_PORT=8000
|
||
APP_DEBUG=false
|
||
BASE_URL=http://127.0.0.1:8000
|
||
APP_TIMEZONE=Asia/Shanghai
|
||
|
||
# ─── 安全 ────────────────────────────────
|
||
ADMIN_USERNAME=admin
|
||
ADMIN_PASSWORD=your_secure_password
|
||
SECRET_KEY=your_random_secret_key
|
||
|
||
# ─── HuggingFace / arXiv ────────────────
|
||
HF_API_BASE=https://huggingface.co/api
|
||
HF_PROXY=
|
||
TOP_N=20
|
||
HTTP_TIMEOUT_SECONDS=30
|
||
HTTP_MAX_RETRIES=3
|
||
HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
||
|
||
# ─── AI 总结 ──────────────────────────────
|
||
# 总结后端:pi | claude
|
||
SUMMARY_BACKEND=pi
|
||
PI_BIN=
|
||
SUMMARY_SKILL=daily-paper-summary
|
||
CLAUDE_BIN=claude
|
||
SUMMARY_CONCURRENCY=3
|
||
SUMMARY_TIMEOUT_SECONDS=1200
|
||
SUMMARY_MAX_RETRIES=2
|
||
SUMMARY_PDF_MODE=auto
|
||
|
||
# ─── 调度 ─────────────────────────────────
|
||
SCHEDULER_ENABLED=false
|
||
SCHEDULE_HOUR=4
|
||
SCHEDULE_MINUTE=0
|
||
# 抓取时自动探测:先试今天,无数据则回退昨天(无需手动配置偏移)
|
||
APP_WORKERS=1
|
||
|
||
# ─── 数据库 ─────────────────────────────
|
||
DATABASE_URL=sqlite:///data/db/papers.db
|
||
|
||
# ─── 语义搜索 ─────────────────────────────
|
||
CHROMA_ENABLED=false
|
||
CHROMA_DIR=data/chroma
|
||
EMBED_API_BASE=https://api.siliconflow.cn
|
||
EMBED_API_KEY=your_api_key_here
|
||
EMBED_MODEL=Qwen/Qwen3-Embedding-4B
|
||
EMBED_DIMENSIONS=2560
|
||
|
||
# ─── 布局检测 ─────────────────────────────
|
||
# DocLayout-YOLO ONNX 模型(首次运行前执行 scripts/export_doclayout_yolo_onnx.py 导出)
|
||
# LAYOUT_MODEL_PATH=data/models/doclayout_yolo_docstructbench_imgsz1024.onnx
|
||
# 模型输入尺寸(DocLayout-YOLO 推荐 1024)
|
||
# LAYOUT_IMGSZ=1024
|
||
# 检测置信度阈值(DocLayout-YOLO 推荐 0.2)
|
||
# LAYOUT_THRESHOLD=0.2
|
||
# 推理设备:auto|cpu|cuda|directml|openvino|cann|tensorrt|qnn
|
||
# auto = 按优先级 [CUDA, DirectML, OpenVINO, CPU] 自动探测,失败降级 CPU
|
||
# LAYOUT_DEVICE=auto
|
||
# 设备 ID(GPU 序号)
|
||
# LAYOUT_DEVICE_ID=0
|
||
#
|
||
# GPU 用户:onnxruntime 与 onnxruntime-gpu/-directml 同环境冲突,需手动二选一:
|
||
# pip uninstall onnxruntime && pip install onnxruntime-gpu # NVIDIA CUDA
|
||
# pip uninstall onnxruntime && pip install onnxruntime-directml # Windows 任意 GPU
|