AutoFigure-Edit README

The project's README from github.com/ResearAI/AutoFigure-Edit. As one markdown file: README.md.

AutoFigure-Edit Logo

AutoFigure-Edit: Generating Editable Scientific Illustration

English | 中文

arXiv 2603.06674 License: MIT Python HuggingFace Website

From Method Text to Editable SVG
AutoFigure-Edit is the next version of AutoFigure. It turns paper method sections into fully editable SVG figures and lets you refine them in an embedded SVG editor.

Quick Start • Web Interface • How It Works • Configuration • Citation

[Paper] [AutoFigure] [BibTeX]


https://github.com/user-attachments/assets/6f93deb4-9854-4f1e-8097-53b0c3378a0d

🔥 News


🆕 V1.1 (2026.04.23)

AutoFigure-Edit v1.1 is published as tag v1.1. This release focuses on two practical workflows that were still awkward in earlier public builds: starting from a user-supplied stage-1 academic figure, and running the pipeline cleanly with official OpenAI models or OpenAI-compatible gateways.

Full release notes: releases/v1.1.md


✨ Features

Feature Description
📝 Text-to-Figure Generate a draft figure directly from method text.
🧠 SAM3 Icon Detection Detect icon regions from multiple prompts and merge overlaps.
🎯 Labeled Placeholders Insert consistent AF-style placeholders for reliable SVG mapping.
🧩 SVG Generation Produce an editable SVG template aligned to the figure.
🖥️ Embedded Editor Edit the SVG in-browser using the bundled svg-edit.
📦 Artifact Outputs Save PNG/SVG outputs and icon crops per run.

AutoFigure-edit introduces two breakthrough capabilities:

  1. Fully Editable SVGs (Pure Code Implementation): Unlike raster images, our outputs are structured Vector Graphics (SVG). Every component is editable—text, shapes, and layout can be modified losslessly.
  2. Style Transfer: The system can mimic the artistic style of reference images provided by the user.

Below are 9 examples covering 3 different papers. Each paper is generated using 3 different reference styles. (Each image shows: Left = AutoFigure Generation | Right = Vectorized Editable SVG)

Paper & Style Transfer Demonstration
CycleResearcher / Style 1
Paper 1 Style 1
CycleResearcher / Style 2
Paper 1 Style 2
CycleResearcher / Style 3
Paper 1 Style 3
DeepReviewer / Style 1
Paper 2 Style 1
DeepReviewer / Style 2
Paper 2 Style 2
DeepReviewer / Style 3
Paper 2 Style 3
DeepScientist / Style 1
Paper 3 Style 1
DeepScientist / Style 2
Paper 3 Style 2
DeepScientist / Style 3
Paper 3 Style 3

🚀 How It Works

The AutoFigure-edit pipeline transforms a raw generation into an editable SVG in four distinct stages:

Pipeline Visualization: Figure -> SAM -> Template -> Final
(1) Raw Generation → (2) SAM3 Segmentation → (3) SVG Layout Template → (4) Final Assembled Vector

  1. Generation (figure.png): The LLM generates a raster draft based on the method text.
  2. Segmentation (sam.png): SAM3 detects and segments distinct icons and text regions.
  3. Templating (template.svg): The system constructs a structural SVG wireframe using placeholders.
  4. Assembly (final.svg): High-quality cropped icons and vectorized text are injected into the template.
View Detailed Technical Pipeline
AutoFigure-edit Technical Pipeline

AutoFigure2’s pipeline starts from the paper’s method text and first calls a text‑to‑image LLM to render a journal‑style schematic, saved as figure.png. The system then runs SAM3 segmentation on that image using one or more text prompts (e.g., “icon, diagram, arrow”), merges overlapping detections by an IoU‑like threshold, and draws gray‑filled, black‑outlined labeled boxes on the original; this produces both samed.png (the labeled mask overlay) and a structured boxlib.json with coordinates, scores, and prompt sources.

Next, each box is cropped from the original figure and passed through RMBG‑2.0 for background removal, yielding transparent icon assets under icons/*.png and *_nobg.png. With figure.png, samed.png, and boxlib.json as multimodal inputs, the LLM generates a placeholder‑style SVG (template.svg) whose boxes match the labeled regions.

Optionally, the SVG is iteratively refined by an LLM optimizer to better align strokes, layouts, and styles, resulting in optimized_template.svg (or the original template if optimization is skipped). The system then compares the SVG dimensions with the original figure to compute scale factors and aligns coordinate systems. Finally, it replaces each placeholder in the SVG with the corresponding transparent icon (matched by label/ID), producing the assembled final.svg.

Key configuration details:

  • Placeholder Mode: Controls how icon boxes are encoded in the prompt (label, box, or none).
  • Optimization: optimize_iterations=0 allows skipping the refinement step to use the raw structure directly.

⚡ Quick Start

Use Docker for a reproducible one-command setup without local Python/SAM3 installation.

0) Prerequisites

1) Prepare .env

# Linux/macOS
cp .env.example .env

# Windows PowerShell
Copy-Item .env.example .env

At minimum, set this in .env:

HF_TOKEN=hf_xxx

Optional but recommended:

# SAM3 API backend (Docker default in UI is Roboflow)
ROBOFLOW_API_KEY=your_roboflow_key

# Step-4 multimodal retry tuning (OpenRouter)
OPENROUTER_MULTIMODAL_RETRIES=3
OPENROUTER_MULTIMODAL_RETRY_DELAY=1.5

# DNS override for Roboflow name-resolution issues
DOCKER_DNS_1=223.5.5.5
DOCKER_DNS_2=119.29.29.29

For restricted networks, you can also set build mirrors:

BASE_IMAGE=docker.m.daocloud.io/library/python:3.11-slim
PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
PIP_EXTRA_INDEX_URL=

2) Build and start

docker compose up -d --build

Open http://localhost:8000.

3) Verify service health

docker compose ps
curl http://localhost:8000/healthz

Expected health response: {"status":"ok"}.

4) Daily operations

# Stream logs
docker compose logs -f autofigure-edit

# Restart service
docker compose restart autofigure-edit

# Rebuild from scratch (no cache)
docker compose build --no-cache
docker compose up -d

# Stop and remove container
docker compose down

5) Persistence and defaults

6) Common Docker networking issues

Option 1: CLI

# 1) Install dependencies
pip install -r requirements.txt

# 2) Install SAM3 separately (not vendored in this repo)
git clone https://github.com/facebookresearch/sam3.git
cd sam3
pip install -e .

Run:

python autofigure2.py \
  --method_file paper.txt \
  --output_dir outputs/demo \
  --provider bianxie \
  --api_key YOUR_KEY

Use OpenAI only for step 1 image generation while keeping SVG reconstruction on the original provider:

python autofigure2.py \
  --method_file paper.txt \
  --output_dir outputs/demo \
  --provider gemini \
  --api_key GEMINI_KEY \
  --image_provider openai \
  --image_api_key OPENAI_KEY \
  --image_model gpt-image-2

Use the OpenAI Responses API for text + multimodal SVG reconstruction:

python autofigure2.py \
  --method_file paper.txt \
  --output_dir outputs/demo \
  --provider openai_response \
  --api_key OPENAI_KEY

Continue from an existing stage-1 figure and skip image generation:

python autofigure2.py \
  --input_figure_path ./my_stage1_figure.png \
  --output_dir outputs/import_demo \
  --provider openai_response \
  --api_key OPENAI_KEY \
  --svg_model gpt-5.5

Option 2: Web Interface

python server.py

Then open http://localhost:8000.


🖥️ Web Interface Demo

AutoFigure-edit provides a visual web interface designed for seamless generation and editing.

1. Configuration Page

Configuration Page

On the start page, paste your paper's method text on the left. On the right, configure your generation settings:

If you already have the first-stage raster figure, use the black button in the top-right corner:

2. Canvas & Editor

Canvas Page

The generation result loads directly into an integrated SVG-Edit canvas, allowing for full vector editing.


🧩 SAM3 Installation Notes

AutoFigure-edit depends on SAM3 but does not vendor it. Please follow the official SAM3 installation guide and prerequisites. The upstream repo currently targets Python 3.12+, PyTorch 2.7+, and CUDA 12.6 for GPU builds.

SAM3 checkpoints are hosted on Hugging Face and may require you to request access and authenticate (e.g., huggingface-cli login) before download.

SAM3 API Mode (No Local Install)

If you prefer not to install SAM3 locally, you can use an API backend (also supported in the Web demo). We recommend using Roboflow as it is free to use.

Option A: fal.ai

export FAL_KEY="your-fal-key"
python autofigure2.py \
  --method_file paper.txt \
  --output_dir outputs/demo \
  --provider bianxie \
  --api_key YOUR_KEY \
  --sam_backend fal

Option B: Roboflow

export ROBOFLOW_API_KEY="your-roboflow-key"
python autofigure2.py \
  --method_file paper.txt \
  --output_dir outputs/demo \
  --provider bianxie \
  --api_key YOUR_KEY \
  --sam_backend roboflow

Optional CLI flags (API):

⚙️ Configuration

Supported LLM Providers

Provider Base URL Notes
OpenRouter openrouter.ai/api/v1 Supports Gemini/Claude/others
Bianxie AI api.bianxie.ai/v1 Built-in OpenAI-compatible aggregate API; supports GPT-image-2 and Gemini-3.1-Pro access for mainland China users without a foreign credit card
Custom <your-compatible-endpoint>/v1 (required) Vendor-neutral OpenAI-compatible API
Gemini (Google) generativelanguage.googleapis.com/v1beta Official Google Gemini API (google-genai)
OpenAI Responses api.openai.com/v1 Uses the official OpenAI Responses API for text + multimodal

Common CLI flags:

Custom Provider / Custom Base URL

If you want to use a self-hosted or third-party OpenAI-compatible endpoint, use:

You can also set AUTOFIGURE_CUSTOM_BASE_URL instead of passing --base_url every time.

base_url must be the OpenAI-compatible /v1 root:

https://your-provider.example/v1

Do not pass a concrete endpoint path such as:

https://your-provider.example/v1/chat/completions

For text reasoning and SVG reconstruction, the Custom route calls:

POST /chat/completions
Authorization: Bearer <api_key>

Text-only requests use the no

AutoFigure-Edit (ResearAI/AutoFigure-Edit)

Searching Database…

这是什么?AutoFigure-Edit 能把研究论文的方法部分文字转换成完全可编辑的 SVG 科学插图,并内置一个 SVG 编辑器用于进一步修改。
这是一个光栅图像生成器,还是不止于此?它是一条流水线(CLI + 带嵌入式 SVG 编辑器的 Web 应用),输出的是结构化、完全可编辑的矢量图形(SVG),而不是扁平的光栅图像。
怎么把它跑起来?推荐的方式是使用 Docker:在 .env 中设置好 API 密钥,然后运行 docker compose 来构建并启动服务,服务会提供 Web 界面(默认端口 8000)。如果你在本地安装了 Python/SAM3,也可以使用直接的 CLI 和独立的 Web 界面。
我需要先准备 API 密钥或本地 GPU 环境吗?你需要一个受支持的大语言模型提供商的 API 密钥(OpenRouter、Bianxie AI、Gemini、OpenAI,或自定义的 OpenAI 兼容端点),还需要用于分割的 SAM3——既可以本地安装,也可以通过 Roboflow/fal.ai API 访问——以及访问 RMBG-2.0 背景移除模型所需的 Hugging Face 访问权限。
安装上有什么需要留意的坑吗?SAM3 并未随项目一起打包——你必须按照上游指南单独安装它,或者改用 Roboflow/fal.ai API 后端来完全跳过这一步。
SAM3 分割这一步具体做什么?SAM3 使用一个或多个文本提示来检测并分割生成的草图figure中各个独立的图标和文字区域,先合并重叠的检测结果,再将图标裁剪并矢量化到 SVG 模板中。
我可以从自己的图开始,而不是从零生成吗?可以,v1.1 新增了上传已有的第一阶段光栅学术插图并跳过初始生成步骤的支持,可以直接从 SAM 分割和 SVG 重建继续。
它支持风格迁移吗?支持,你可以上传一张参考图,系统在生成插图时会模仿其艺术风格,画廊中展示了每篇论文的多种风格变体。
Creator
ResearAI
Size
112.9 MB
Stars
4.4K
Age
8mo
Commits · 90 Days