Install
openclaw skills install @davidzhao30/scientific-drawing-skill-1-0-0基于 AutoFigure-Edit 的科研级科学插图生成与编辑系统,能够从长篇方法描述自动生成完全可编辑的矢量图(SVG),支持参考图风格迁移和浏览器内交互式编辑
openclaw skills install @davidzhao30/scientific-drawing-skill-1-0-0基于 AutoFigure-Edit 的科研级科学插图生成与编辑系统,能够从长篇方法描述自动生成完全可编辑的矢量图(SVG),支持参考图风格迁移和浏览器内交互式编辑。
# 在OpenClaw环境中,只需激活技能即可自动安装
# 技能会检查并安装所有依赖
# 克隆AutoFigure-Edit仓库
git clone https://github.com/ResearAI/AutoFigure-Edit.git
# 进入技能目录
cd /home/davidzhao/.openclaw/workspace/skills/scientific-drawing-skill
# 安装Python依赖
pip install -r requirements.txt
# 安装额外依赖
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
pip install transformers datasets accelerate
pip install opencv-python pillow scikit-image
pip install lxml svgwrite svgpathtools
pip install flask flask-cors
# 复制环境配置文件
cp .env.example .env
# 编辑.env文件,添加你的API密钥
# GEMINI_API_KEY=your_gemini_api_key_here
# OPENROUTER_API_KEY=your_openrouter_api_key_here
# HF_TOKEN=your_huggingface_token_here
# 方法1:使用技能工具
scientific_drawing_generate --text "论文方法描述文本" --output_dir ./output
# 方法2:直接调用Python脚本
python autofigure2.py --method_file paper_method.txt --output_dir ./output --api_key $GEMINI_API_KEY
# 上传参考图并生成风格化插图
scientific_drawing_style_transfer \
--text "方法描述" \
--reference_image style_reference.png \
--output_dir ./styled_output
# 启动本地编辑服务器
scientific_drawing_edit_server --port 8080
# 在浏览器中打开 http://localhost:8080
# 上传生成的SVG文件进行可视化编辑
# 处理目录中的所有文本文件
scientific_drawing_batch \
--input_dir ./papers \
--output_dir ./figures \
--style_reference ./lab_style.png
scientific_drawing_generate从文本生成可编辑的科学插图SVG。
参数:
--text: 论文方法描述文本(可直接提供或通过文件)--method_file: 包含方法描述的文本文件路径--output_dir: 输出目录路径--api_provider: API提供商 (gemini, openrouter, bianxie)--api_key: API密钥(如未在.env中设置)--placeholder_mode: 占位符模式 (none, box, label)--sam_prompt: SAM3检测提示词,逗号分隔 (如 "icon,diagram,arrow")--style_reference: 风格参考图路径(可选)示例:
scientific_drawing_generate \
--text "Our method consists of three modules: feature extraction, attention fusion, and classification. The feature extractor uses ResNet-50..." \
--output_dir ./figure_output \
--placeholder_mode label \
--sam_prompt "icon,module,arrow,text"
scientific_drawing_style_transfer基于参考图进行风格迁移。
参数:
--text: 方法描述文本--reference_image: 风格参考图路径--output_dir: 输出目录--style_strength: 风格迁移强度 (0.0-1.0)--preserve_content: 是否保持内容结构 (true/false)示例:
scientific_drawing_style_transfer \
--method_file paper.txt \
--reference_image nature_style.png \
--output_dir ./nature_style_figures \
--style_strength 0.7
scientific_drawing_edit_server启动交互式SVG编辑服务器。
参数:
--port: 服务器端口 (默认: 8080)--host: 绑定主机 (默认: 0.0.0.0)--data_dir: SVG文件存储目录示例:
scientific_drawing_edit_server --port 8080
# 访问 http://localhost:8080 使用编辑器
scientific_drawing_batch批量处理多篇论文。
参数:
--input_dir: 包含文本文件的输入目录--output_dir: 输出目录--style_reference: 统一的风格参考图(可选)--threads: 并行处理线程数技能使用以下配置文件:
config.yaml# API配置
api:
default_provider: "gemini"
gemini:
model: "gemini-2.0-flash-exp"
temperature: 0.7
openrouter:
model: "openai/gpt-4o"
temperature: 0.7
# 生成参数
generation:
placeholder_mode: "label"
sam_prompt: "icon,diagram,arrow,chart,module"
merge_threshold: 0.9
optimize_iterations: 2
# 风格迁移
style_transfer:
default_strength: 0.8
content_preservation: true
# 编辑器设置
editor:
port: 8080
allow_upload: true
max_file_size: 50MB
# API密钥
GEMINI_API_KEY=your_gemini_api_key_here
OPENROUTER_API_KEY=your_openrouter_api_key_here
BIANXIE_API_KEY=your_bianxie_api_key_here
HF_TOKEN=your_huggingface_token_here
# 模型路径
SAM3_MODEL_PATH=./models/sam3
RMBG2_MODEL_PATH=./models/rmbg2
# 缓存设置
CACHE_DIR=./cache
MAX_CACHE_SIZE=10GB
每次生成会创建以下文件:
output_dir/
├── figure.png # 初始生成的栅格图
├── samed.png # SAM3分割结果
├── boxlib.json # 检测框坐标和标签
├── template.svg # SVG模板
├── optimized_template.svg # 优化后的模板
├── final.svg # 最终可编辑SVG
├── final.png # 最终渲染图
└── icons/ # 提取的图标资产
├── icon_AF01_nobg.png
├── icon_AF02_nobg.png
└── ...
# 使用自定义图标替换默认生成
scientific_drawing_generate \
--text "方法描述" \
--custom_icons ./my_icons/ \
--icon_mapping ./mapping.json
# 结合文本和草图生成
scientific_drawing_multimodal \
--text "方法描述" \
--sketch ./sketch.png \
--output_dir ./output
# 生成符合期刊要求的插图
scientific_drawing_publish \
--input_svg ./final.svg \
--journal "Nature" \
--output_dir ./nature_ready
API密钥错误
Error: Invalid API key
解决方案: 检查.env文件中的API密钥,或通过--api_key参数提供
内存不足
CUDA out of memory
解决方案: 使用--no_cuda参数切换到CPU模式,或减小图片尺寸
SAM3检测不准确
No icons detected
解决方案: 调整--sam_prompt参数,尝试更具体的提示词
SVG生成失败
Failed to generate SVG
解决方案: 检查网络连接,尝试减少--optimize_iterations次数
# 启用详细日志
export SCIENTIFIC_DRAWING_DEBUG=1
scientific_drawing_generate --text "..." --output_dir ./debug
# 查看完整日志
tail -f ./debug/generation.log
# 启用CUDA加速(如有NVIDIA GPU)
export CUDA_VISIBLE_DEVICES=0
scientific_drawing_generate --use_cuda ...
# 启用结果缓存,加速重复生成
scientific_drawing_generate --enable_cache ...
# 批量处理时使用多线程
scientific_drawing_batch --threads 4 ...
# 在Python脚本中使用
from scientific_drawing_skill import generate_scientific_figure
result = generate_scientific_figure(
method_text="...",
output_dir="./figures",
style_reference="./lab_style.png"
)
print(f"生成成功: {result['svg_path']}")
# 从arXiv论文自动生成插图
arxiv_paper_to_figures \
--arxiv_id "2603.06674" \
--output_dir ./paper_figures \
--style_reference ./journal_style.png
# 更新技能到最新版本
clawhub update scientific-drawing-skill
# 重新安装所有Python依赖
cd /home/davidzhao/.openclaw/workspace/skills/scientific-drawing-skill
pip install -r requirements.txt --upgrade
# 清除生成的缓存文件
scientific_drawing_clean_cache --all
本技能基于MIT许可证开源。
如果您在研究中使用了本技能,请引用以下论文:
@article{lin2026autofigureedit,
title={AutoFigure-Edit: Generating Editable Scientific Illustration},
author={Lin, Zhen and Xie, Qiujie and Zhu, Minjun and Li, Shichen and Sun, Qiyao and Gu, Enhao and Ding, Yiran and Sun, Ke and Guo, Fang and Lu, Panzhong and Ning, Zhiyuan and Weng, Yixuan and Zhang, Yue},
journal={arXiv preprint arXiv:2603.06674},
year={2026}
}
如在技能使用中遇到问题,请:
欢迎提出新功能建议或改进意见:
欢迎提交Pull Request改进本技能:
为了持续改进本技能,我们非常重视您的使用体验反馈。请通过以下方式提供反馈:
请回答以下问题帮助我们改进:
报告问题时请提供以下信息:
- OpenClaw版本:
- 技能版本: 1.0.0
- 操作系统:
- Python版本:
- API提供商:
- 错误信息:
- 复现步骤:
- 期望结果:
- 实际结果:
- 相关截图/日志:
技能会匿名收集以下使用数据以改进性能:
隐私说明: 所有数据均为匿名收集,不会包含个人身份信息或具体内容数据。
让科学插图生成变得简单而强大! 🚀
技能版本: 1.0.0 | 最后更新: 2026-04-07