将课件截图智能转换为可编辑 PPT,专为教育场景设计。
- 智能分层:基于 Qwen-Image-Layered 将图片分解为背景、文字、前景三层
- 高保真重构:背景层 Real-ESRGAN 4x 超分,前景层 Guided Filter 高保真迁移
- 精准 OCR:VLM 识别可编辑文字,自动生成文本框(保留字体、颜色、位置)
- 双模式支持:
instruction模式:指令式分层描述,可选智能图层预测caption模式:VLM 生成图片描述
原图 → VLM分析 → Qwen分层 → 双流重构 → PPT生成
↓
┌─────────┴─────────┐
↓ ↓
背景层(超分) 前景层(Mask Transfer)
↓ ↓
Real-ESRGAN 4x Guided Filter
↓ ↓
└─────────┬─────────┘
↓
PPT Builder
# 使用 uv(推荐)
uv sync
# 或使用 pip
pip install -r requirements.txt创建 .env 文件:
# Replicate API(Qwen 分层 + Real-ESRGAN 超分)
REPLICATE_API_TOKEN=r8_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# VLM API(OCR + 图层预测)
VLM_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
VLM_BASE_URL=https://api.openai.com/v1
VLM_MODEL=gpt-4o# 批量处理(input 目录下的所有子文件夹)
python image2ppt.py
# 指定输入输出
python image2ppt.py --input ./my_slides --output ./my_output
# 单项目模式
python image2ppt.py --input ./my_slides --output ./output --single-project
# 启用智能图层预测(instruction 模式)
python image2ppt.py --smart-layers
# 使用 caption 模式
python image2ppt.py --description-mode captionimage2ppt/
├── image2ppt.py # 主程序
├── pyproject.toml # 项目配置
├── requirements.txt # 依赖列表
├── .env # 环境变量(不提交)
├── input/ # 输入目录
│ └── 项目名/ # 每个子文件夹是一个项目
│ ├── slide1.png
│ └── slide2.png
└── output/ # 输出目录
└── 项目名/
└── 项目名_instruction.pptx
在 image2ppt.py 顶部可调整配置:
| 配置项 | 默认值 | 说明 |
|---|---|---|
DESCRIPTION_MODE |
"instruction" |
分层描述模式 |
ENABLE_SMART_LAYER_COUNT |
False |
智能图层预测(仅 instruction 模式) |
QWEN_DEFAULT_LAYERS |
3 |
默认图层数 |
MAX_CONCURRENCY |
5 |
最大并发数 |
SAVE_INTERMEDIATE_ASSETS |
False |
保存中间资产 |
根据模式自动添加后缀:
项目名_caption.pptx- caption 模式项目名_instruction.pptx- instruction 模式项目名_instruction_smart.pptx- instruction + 智能图层预测
- Qwen-Image-Layered:图片分层(背景/文字/前景)
- Real-ESRGAN:背景超分辨率
支持 OpenAI 兼容接口,推荐模型:
- GPT-4o / GPT-4o-mini
- Gemini Pro Vision
- Qwen-VL-Max
- 分层引擎:Qwen-Image-Layered (Replicate)
- 超分引擎:Real-ESRGAN 4x (Replicate)
- 前景迁移:Guided Filter + Color Decontamination
- PPT 生成:python-pptx
- 异步框架:asyncio + aiohttp
MIT