这是一个面向动漫周边设计稿审核的本地 Python 项目。当前主链路会从 PPT 设计稿中解析 case,检索素材图,再按规则引擎输出每个 case 的审核结果与汇总结果。
PPT -> parse -> retrieval -> rules -> final result
- 统一
Case Schema,贯穿解析、检索、规则执行和最终汇总 - 统一 pipeline 入口,支持整链路批处理
parse / retrieval / rules三段缓存和断点续跑- rule engine 已拆分为 routing、policy、execution、skills 等模块
- 支持
code / vlm / hybrid三类规则决策来源 - 提供 demo、训练脚本、评测脚本和基础测试
ip-supervision-agent/
├── assets/ # 检索素材与 embeddings
├── baseline_artifacts/ # 基线数据与标注样例
├── core/ # 配置、schema、runtime 检查
├── demo/ # 本地演示页面与服务
├── docs/ # 方案文档与阶段记录
├── modules/
│ ├── asset_retrieval/ # 素材检索
│ ├── ppt_parser/ # PPT 解析、页面预处理、page selection
│ └── rule_engine/ # 路由、策略、执行图、规则技能
├── pipeline/ # 总入口
├── scripts/ # 训练、评测、数据处理脚本
├── tests/ # 回归与 golden tests
├── deploy_bundle/ # 部署裁剪版依赖与说明
└── requirements.txt
- Pipeline: pipeline/run_pipeline.py
- PPT 解析:
modules.ppt_parser.parse_ppt - 素材检索:
modules.asset_retrieval.retrieve_assets - 规则执行:
modules.rule_engine.run_rules
Python 调用示例:
from pipeline.run_pipeline import run_pipeline
cases = run_pipeline("example2.pptx", output_root="outputs", max_cases=1)
print(len(cases))建议使用 Python 3.10+,并在虚拟环境中安装:
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txtrequirements.txt 当前包含的核心依赖包括:
python-pptxsentence-transformersopenaiscikit-learnPillownumpyPyMuPDFtorch/torchvision/torchaudioopencv-pythonfaiss-cpupaddleocr/paddlepaddlerapidfuzz
运行 pipeline 前,默认会执行 runtime 检查,主要验证:
- 输入 PPT 是否存在
assets/retrieval/embeddings/下的embeddings.npy和image_paths.json是否存在- 关键依赖是否已安装
- 检索模型是否能正常 warmup
- OCR 运行时是否可用
- 输出目录是否可写
相关实现见 core/runtime_checks.py。
如果只想调试流程,可以跳过启动检查:
python pipeline/run_pipeline.py example2.pptx --skip-runtime-check执行整条主链路:
python pipeline/run_pipeline.py example2.pptx --output-root outputs --max-cases 1常用参数:
--output-root输出目录--max-cases仅处理前 N 个 case--skip-runtime-check跳过启动检查--force-parse强制重跑解析阶段--force-retrieval强制重跑检索阶段--force-rules强制重跑规则阶段
尽量复用缓存的调试命令:
python pipeline/run_pipeline.py example2.pptx --output-root outputs --max-cases 1 --skip-runtime-check每个 case 的产物默认落在 outputs/<case_id>/:
outputs/<case_id>/
├── parsed/
│ ├── case.json
│ ├── cache_metadata.json
│ ├── image_candidates/
│ ├── design_images/
│ └── material_images/
├── retrieval/
│ ├── case.json
│ ├── cache_metadata.json
│ ├── retrieval_results.json
│ └── retrieval_candidates.json
├── rules/
│ ├── case.json
│ ├── cache_metadata.json
│ ├── rule_results.json
│ ├── routing.json
│ └── vlm_prescreen.json
└── final/
├── case.json
├── final_result.json
└── summary.json
Pipeline 根目录还会生成 pipeline_summary.json。
统一结构定义见 core/case_schema.py。
主要字段包括:
basic_infoimage_candidatesdesign_imagesmaterial_imagesretrieval_resultsrule_resultsartifacts
其中:
image_candidates是 parser 阶段输出的候选图层design_images / material_images是后续流程直接消费的兼容视图rule_results中会携带decision_source、confidence、evidence、target_id等字段
规则执行入口在 modules/rule_engine/init.py,当前主要由这些部分组成:
routing: 选择当前 case 应该检查的目标图policy: 决定某个 target 走什么比较/执行策略execution: 执行规则计划并汇总结果skills: 规则技能注册与调度tools: 具体检测器实现
当前规则大体分为三类:
code rules: 如rule1、rule2、rule4、rule6vlm rules: 如rule5hybrid rules: 如rule8
decision_source 当前会落成 code、vlm、hybrid 或 system。
主要配置集中在 core/config.py。
常见可调项包括:
- 输出目录、检索资源目录
- parser 阈值与 CLIP / LLM 配置
- routing 权重与 VLM 参数
RULE1_REVIEW_MODERULE6_SEGMENTATION_BACKENDLIBREOFFICE_SOFFICE_PATH
如果使用 .env,这些环境变量会在启动时自动加载。
项目里保留了 V3 page-level selection 相关能力。当 Portable LibreOffice 不能稳定从 Python 子进程启动时,可以先把标注后的 PPT 显式转成 PDF,再复用 PDF 做页面级选择。
手动转换:
powershell -ExecutionPolicy Bypass -File scripts/convert_annotated_ppt_to_pdf.ps1 `
-AnnotatedPptPath "path\to\example_page_preprocess_annotated.pptx" `
-OutputPdfPath "path\to\example_page_preprocess_annotated.pdf"一键串联 page preprocess + PDF 转换 + page selection:
powershell -ExecutionPolicy Bypass -File scripts/run_v3_page_selection_with_pdf.ps1 `
-PptPath "example2.pptx" `
-OutputDir "outputs_v3_page_selection"如果 PDF 已经准备好,可以跳过转换:
powershell -ExecutionPolicy Bypass -File scripts/run_v3_page_selection_with_pdf.ps1 `
-PptPath "example2.pptx" `
-OutputDir "outputs_v3_page_selection" `
-SkipPdfConversion本地演示说明见 demo/README.md。
直接启动:
powershell -ExecutionPolicy Bypass -File .\demo\run_demo.ps1默认地址:
http://127.0.0.1:8000/demo/- 健康检查:
http://127.0.0.1:8000/api/health
仓库当前包含 page preprocess、routing、policy、rule skill、golden baseline 等测试。可按需运行:
pytest tests如果只看某一类:
pytest tests/test_run_rules_graph_integration.py- PROJECT_HANDOFF.md
- deploy_bundle/README.md
- baseline_artifacts/README.md
- docs/BENCHMARK_PLAN_4MONTH.md
阶段性实验记录保存在 docs/archive/,不再放在根 README 中堆叠维护。