Pengyu965 commited on
Commit
2e1ea87
Β·
verified Β·
1 Parent(s): f950463

Add model card

Browse files
Files changed (1) hide show
  1. README.md +118 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-VL-7B-Instruct
4
+ pipeline_tag: image-text-to-text
5
+ library_name: transformers
6
+ language:
7
+ - en
8
+ datasets:
9
+ - Pengyu965/StructHub
10
+ tags:
11
+ - svg
12
+ - xml
13
+ - image-to-svg
14
+ - structured-images
15
+ - diagrams
16
+ - vector-graphics
17
+ - qwen2.5-vl
18
+ - grpo
19
+ - reinforcement-learning
20
+ - multimodal
21
+ ---
22
+
23
+ # Back2Struct-Image2SVG-7B
24
+
25
+ **Back2Struct** recovers **editable, object-level SVG / XML code** from images of structured
26
+ graphics (diagrams, charts, flowcharts, architecture figures, UML, schemas). Instead of
27
+ low-level pixel vectorization, it predicts vector primitives that explicitly encode text,
28
+ shapes, topology, and layout β€” so the output can be imported into tools like PowerPoint and
29
+ edited, restyled, and reused while preserving structural fidelity.
30
+
31
+ This checkpoint is the reinforcement-learning model (**GRPO checkpoint-2200**), fine-tuned
32
+ from `Qwen/Qwen2.5-VL-7B-Instruct`.
33
+
34
+ - πŸ“„ Paper: *Back2Struct: Making Structured Images Editable Again*
35
+ - πŸ”— Project page: https://pengyu965.github.io/Back2Struct.github.io/
36
+ - πŸ“š Dataset: [`Pengyu965/StructHub`](https://huggingface.co/datasets/Pengyu965/StructHub)
37
+
38
+ ## Training
39
+
40
+ | | |
41
+ |---|---|
42
+ | **Base model** | Qwen/Qwen2.5-VL-7B-Instruct (7B) |
43
+ | **Stage 1 β€” SFT** | Supervised fine-tuning on StructHub imageβ†’SVG pairs (≀ 8,192 tokens) |
44
+ | **Stage 2 β€” GRPO** | Group-Relative Policy Optimization (TRL), checkpoint **2200** |
45
+ | **Reward** | Composite, render-gated: syntactic validity (must render) Γ— perceptual fidelity β€” a baseline-subtracted DINOv2 similarity between the rendered prediction and the target image; encourages compilability, length consistency, and structural/semantic faithfulness |
46
+ | **Max output length** | 8,192 tokens |
47
+ | **Adapter** | LoRA (r=64, Ξ±=128), merged into the released weights |
48
+
49
+ ## Results
50
+
51
+ **StructHub benchmark (1,000 samples), render-gated evaluation** β€” a non-rendering prediction
52
+ scores 0 on DINO/SSIM/GPT and 1 on LPIPS. SR = render success (%); GPT = 0–100 GPTScore.
53
+
54
+ | Model | SR ↑ | DINO ↑ | LPIPS ↓ | SSIM ↑ | GPT ↑ |
55
+ |-------|-----:|-------:|--------:|-------:|------:|
56
+ | Qwen3-VL-30B-A3B | 18.8 | 0.1566 | 0.9067 | 0.1201 | 13.29 |
57
+ | StarVector-8B | 31.4 | 0.2694 | 0.7936 | 0.2170 | 21.05 |
58
+ | Qwen2.5-VL-7B (base) | 52.3 | 0.3527 | 0.7834 | 0.3276 | 27.56 |
59
+ | Qwen2.5-VL-7B (SFT) | 42.8 | 0.3715 | 0.7403 | 0.2891 | 33.49 |
60
+ | **Back2Struct (RL, this model)** | **71.5** | **0.5622** | **0.6473** | **0.4966** | **51.85** |
61
+
62
+ **On successfully compiled outputs**, the 7B model matches or beats frontier closed models:
63
+
64
+ | Model | DINO ↑ | LPIPS ↓ | SSIM ↑ | GPT ↑ |
65
+ |-------|-------:|--------:|-------:|------:|
66
+ | Gemini-2.5-Pro | **0.8855** | 0.4648 | 0.6532 | 77.95 |
67
+ | GPT-5 | 0.8852 | 0.4350 | 0.6573 | 77.21 |
68
+ | **Back2Struct (7B)** | 0.8697 | **0.3896** | **0.6738** | **78.63** |
69
+
70
+ ## Usage
71
+
72
+ ```python
73
+ import torch
74
+ from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
75
+ from qwen_vl_utils import process_vision_info
76
+
77
+ model_id = "Pengyu965/Back2Struct-Image2SVG-7B"
78
+ model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
79
+ model_id, torch_dtype=torch.bfloat16, device_map="auto")
80
+ processor = AutoProcessor.from_pretrained(model_id)
81
+
82
+ messages = [{
83
+ "role": "user",
84
+ "content": [
85
+ {"type": "image", "image": "diagram.png"},
86
+ {"type": "text", "text": "Convert this structured image into editable SVG/XML code."},
87
+ ],
88
+ }]
89
+
90
+ text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
91
+ image_inputs, video_inputs = process_vision_info(messages)
92
+ inputs = processor(text=[text], images=image_inputs, videos=video_inputs,
93
+ padding=True, return_tensors="pt").to(model.device)
94
+
95
+ generated = model.generate(**inputs, max_new_tokens=8192, do_sample=False)
96
+ svg = processor.batch_decode(
97
+ generated[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)[0]
98
+ print(svg) # render with cairosvg or import into PowerPoint
99
+ ```
100
+
101
+ ## Intended use & limitations
102
+
103
+ - **Intended use:** recovering editable vector code from images of *structured* graphics.
104
+ - **Not for:** photographic / natural-image vectorization.
105
+ - **Limitations:** built on a general (non-code-specialized) VLM backbone; outputs are capped
106
+ at 8,192 tokens, which bounds the complexity of very large diagrams; very long / dense
107
+ graphics (the *hard* tier) remain the main failure mode (render reliability).
108
+
109
+ ## Citation
110
+
111
+ ```bibtex
112
+ @article{yan2026back2struct,
113
+ title = {Back2Struct: Making Structured Images Editable Again},
114
+ author = {Yan, Pengyu and Wu, Yixin and Tian, Yunjie and Doermann, David},
115
+ year = {2026},
116
+ note = {Preprint}
117
+ }
118
+ ```