Run this model with HF Jobs
Run moonbox-dev/OmniSVG1.1_4B-TensorRT on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/moonbox-dev/OmniSVG1.1_4B-TensorRT. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/moonbox-dev/OmniSVG1.1_4B-TensorRT on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use moonbox-dev/OmniSVG1.1_4B-TensorRT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TensorRT
How to use moonbox-dev/OmniSVG1.1_4B-TensorRT with TensorRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
OmniSVG 1.1 (4B) TensorRT
TensorRT engines of OmniSVG 1.1 (4B), made by Moonbox for NVIDIA RTX GPUs. Each precision is one folder holding the
engine, trt_runner.py (a small numpy runner: TensorRT plus Polygraphy, no PyTorch) and a script that does the rest
of the pipeline. What the engine takes and returns is under How to run.
Compatibility. The engines are built hardware compatible (Ampere and newer: RTX 30, 40 and 50 series) and
version compatible (any TensorRT 10.x from 10.13 on, through its lean runtime). That costs a little speed against an
engine built for one GPU, but no rebuild is needed. Install the runtime with
pip install "tensorrt-cu12>=10.13,<11" "tensorrt-lean-cu12>=10.13,<11" polygraphy numpy.
Files
The last column is the benchmark (details under How to run).
| Precision | File | Size | sha256 | Benchmark |
|---|---|---|---|---|
| fp16 | fp16/LICENSE-Qwen.txt |
7.4 kB | b5c0e5cf74cf |
same draw as the original 99.4 % of teacher-forced steps (ONNX fp16 99.5 %; per case within 0.1 point), 26 of 64 sequences identical, 32 / 32 candidates valid; 789 s for the 8 cases (ONNX fp16 803 s) |
| fp16 | fp16/LICENSE.txt |
11.6 kB | 1eb85fc97224 |
(the same build: numbers in its first row) |
| fp16 | fp16/NOTICE.txt |
0.3 kB | 56abb7ae4a23 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_0.engine |
652.0 MB | 0b798b668f27 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_1.engine |
672.8 MB | 0c621007fc7f |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_10.engine |
851.3 MB | 8d425d168eb3 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_11.engine |
44.3 MB | 45bfc5fb8c1d |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_2.engine |
672.8 MB | aab4dc8c0655 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_3.engine |
672.8 MB | 7d12a99a215b |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_4.engine |
672.8 MB | 32adafb7b28e |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_5.engine |
672.8 MB | 244880409b28 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_6.engine |
673.0 MB | 1a3c876ae3fa |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_7.engine |
672.8 MB | b59979afd09f |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_8.engine |
672.8 MB | 9c597c57dd57 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_9.engine |
202.7 MB | c9b58ede9f30 |
(the same build: numbers in its first row) |
| fp16 | fp16/decoder_split.json |
6.4 kB | c21753a381be |
(the same build: numbers in its first row) |
| fp16 | fp16/device_chain.py |
8.3 kB | e675d2e7e2d1 |
(the same build: numbers in its first row) |
| fp16 | fp16/embed.onnx.data |
806.9 MB | df8b0874e196 |
(the same build: numbers in its first row) |
| fp16 | fp16/pipeline.py |
27.0 kB | 3ed5f90b7020 |
(the same build: numbers in its first row) |
| fp16 | fp16/pipeline_trt.py |
5.7 kB | b0dd2a3ca38c |
(the same build: numbers in its first row) |
| fp16 | fp16/tokenizer.json |
7.0 MB | c0382117ea32 |
(the same build: numbers in its first row) |
| fp16 | fp16/trt_runner.py |
4.4 kB | cbc9abb1f59c |
(the same build: numbers in its first row) |
| fp16 | fp16/vision_0.engine |
758.6 MB | 477a2fbd0ce0 |
(the same build: numbers in its first row) |
| fp16 | fp16/vision_1.engine |
745.9 MB | 2d734752aa65 |
(the same build: numbers in its first row) |
| fp16 | fp16/vision_2.engine |
65.4 MB | a1b5cab5c85a |
(the same build: numbers in its first row) |
| fp16 | fp16/vision_split.json |
0.6 kB | acf64fabb433 |
(the same build: numbers in its first row) |
How to run
OmniSVG 1.1 (4B: text-to-SVG and image-to-SVG; Qwen2.5-VL-3B fine-tuned to emit SVG path commands, coordinates and
colours as tokens) as TensorRT engines built from this model's fp16 ONNX graphs, plus pipeline_trt.py. The pipeline
is the ONNX build's pipeline.py (the repository's prompts and per-task sampling, 8 sequences of up to 1,536 tokens,
deepsvg's path strings, the candidates' render check) with its graphs run as engines. Non-commercial use only: the
4B model is built on Qwen2.5-VL-3B-Instruct, which is under the Qwen Research Licence (LICENSE-Qwen.txt and
NOTICE.txt in the folder; OmniSVG's own licence is Apache-2.0, LICENSE.txt). Built with Qwen.
import sys
from PIL import Image
sys.path.insert(0, "fp16")
from pipeline_trt import OmniSVGTrt
p = OmniSVGTrt("fp16")
svgs = p("A red heart shape with smooth curved edges, centered.") # up to 4 candidate SVG strings
svgs = p(image=Image.open("logo.png")) # image-to-SVG
Or python fp16/pipeline_trt.py "A red heart shape" heart.svg [--image logo.png]. It needs numpy, tokenizers,
Pillow, resvg-py (or cairosvg) for the candidates' check, TensorRT 10.13 (tensorrt-cu12 or tensorrt-lean-cu12)
and Polygraphy. No PyTorch and no ONNX Runtime. The engines are version-compatible and built for Ampere or newer GPUs
(RTX 30-series and up). They hold 8.7 GB. The benchmark's process peaked at 9.7 GB of memory on text prompts and
11.4 GB on images, GPU memory included (the ONNX fp16 build: 9.0-11.0 and 11.3 GB). It is no faster than the ONNX
fp16 build (789 vs 803 s for the 8 benchmark cases); it is for running without ONNX Runtime.
The engines.
vision_0..2.engine: the vision tower, one 448 x 448 image:pixel_values[1024, 1176],position_ids[1024, 2],window_index/reverse_index[256],window_mask[1024, 1024] ->image_embeds[256, 2048].vision_split.jsongives the order of the pieces and the tensors passed between them.decoder_0..11.engine: the 36-layer decoder with 3-D M-RoPE (decoder_split.json):inputs_embeds[B, S, 2048],position_ids[3, B, S],past_key_values.{0..35}.key / .value[B, 2, P, 128] (fp16) ->logitsof the last position [B, 197000] andpresent.*. The decoder and the vision tower are cut into pieces of at most 0.7 GB of weights, so that each engine builds within the build machine's memory.- The token embedding is not an engine:
pipeline_trt.pyreads it from a read-only memory map ofembed.onnx.data, as the ONNX build'spipeline.pydoes.
Limits. Up to 8 sequences (the pipeline's 4 candidates + 4 spare), a prompt up to 640 positions (the system prompt, the instruction and an image's 256 tokens), and the prompt plus 1,536 new tokens.
On the GPU. The pipeline (device_chain.py) keeps the decoder's KV cache on the GPU: each step reads one set of
buffers and writes the longer cache into the other, so a step allocates nothing. The prompt's cache is computed once
and repeated for the 8 sequences. The activations between pieces never leave the GPU.
Precisions. fp16/ is strongly typed: every tensor keeps the precision the ONNX graph gives it (the fp32 residual
stream, decoder layer 2's and vision blocks 17 / 31's MLPs in fp32, where Qwen2.5 overflows fp16), with these changes:
- both graphs' softmax computed in fp32, as ONNX Runtime's kernel computes it;
- the decoder's KV cache is fp16 at its inputs and outputs too (exact: the graph computes it in fp16);
- the window mask's -inf is passed as fp16's lowest value, -65504 (the same softmax): with -inf, TensorRT's fused attention returns NaN.
No int8: TensorRT's int8 needs calibrated activations, and the ONNX int8/ / int4/ builds are weight-only
MatMulNBits, which TensorRT doesn't take.
Benchmark.
- Setup: the ONNX build's benchmark. Six of the repository's example prompts and two example images, the repository's per-task sampling settings, 8 sequences each, with the original's (PyTorch bf16) random draws replayed. RTX 3080 Laptop GPU.
- Same draw: the original's tokens fed back; how often the build's sampled token (with the original's draw) is the original's. Identical: of the 8 sequences per case, how many the build generates exactly. Valid: candidates that pass the original's check (an SVG whose render isn't empty).
- Pass mark (set before the first run): per case, same draw at most 1 point below the ONNX fp16 build's, and all 32 candidates valid.
| same draw (heart / checkmark / database / thermometer / character / desert / image 1 / image 2) | identical | valid | seconds (8 cases) | |
|---|---|---|---|---|
ONNX fp16/ (ONNX Runtime CUDA) |
99.6 / 99.2 / 99.5 / 99.7 / 99.3 / 99.9 / 99.3 / 98.9 % | 26 / 64 | 32 / 32 | 803 |
TensorRT fp16/ |
99.6 / 99.2 / 99.5 / 99.7 / 99.3 / 99.9 / 99.4 / 98.9 % | 26 / 64 | 32 / 32 | 789 |
The seconds are from the prompt to the 8 finished sequences, with the decoder already loaded; the vision tower loads on first use, as in the ONNX build. A full-length run (8 x 1,536 tokens) takes about 170-190 s, a short icon 10-40 s.
How these were made
From OmniSVG 1.1 (4B) at revision 117d4c4541: each engine was built with TensorRT's builder from Moonbox's published
ONNX graph of the same model and precision. The network is strongly typed: every tensor keeps the precision the
ONNX graph gives it, so an fp16 engine computes what the fp16 ONNX build computes. Built on an RTX 3080 Laptop GPU,
it was benchmarked against the original before upload, and the sha256 column above is what the files must hash to.
License
Apache-2.0 (OmniSVG) + Qwen Research License (base Qwen2.5-VL-3B-Instruct: non-commercial). These files are a derivative of the original model and carry its license: it is copied in this repository, and it governs your use of these files. The original model card follows unchanged.
Original model card
OmniSVG: A Unified Scalable Vector Graphics Generation Model
1. Introduction
OmniSVG is the first family of end-to-end multimodal SVG generators that leverage pre-trained Vision-Language Models (VLMs), capable of generating complex and detailed SVGs, from simple icons to intricate anime characters. We also introduce MMSVG-2M, a multimodal dataset with two million richly annotated SVG assets, along with a standardized evaluation protocol for conditional SVG generation tasks.
2. Models Downloading
| Model | Download link | Size | Update date |
|---|---|---|---|
| OmniSVG1.1-4B | π€ Huggingface | 7.6 GB | 2025-12-02 |
3. Dependencies and Installation
The dependencies configured according to the following instructions provide an environment equipped for inference
3.1 Clone the Repository
git clone https://github.com/OmniSVG/OmniSVG.git
cd OmniSVG
3.2 Create Conda Environment
Create and activate a new conda environment with Python 3.10:
conda create -n omnisvg python=3.10
conda activate omnisvg
3.3 Install Dependencies
System Dependencies
Before installing Python packages, you need to install Cairo library which is required by CairoSVG in our dependencies:
macOS:
brew install cairo
Linux (Ubuntu/Debian):
sudo apt update
sudo apt install libcairo2 libcairo2-dev
Note: Installing Cairo system library beforehand helps prevent potential build errors when installing
CairoSVGvia pip.
Python Dependencies
We have tested our environment with CUDA 12.1. You can install CUDA 12.1 by following the CUDA Toolkit installation guide.
Install PyTorch with CUDA 12.1 support:
pip install torch==2.3.0+cu121 torchvision==0.18.0+cu121 --index-url https://download.pytorch.org/whl/cu121
Install remaining dependencies:
pip install -r requirements.txt
4. Inference Script
| GPU Memory Usage | Time per 256/512/1024/2048/4096 tokens | |
|---|---|---|
| OmniSVG1.1-4B | 16G | 4.08/8.68/18.07/37.51/82.70 seconds |
Note: The inference time shown here is measured per OmniSVG SVG tokens, while the inference time reported in our paper is measured per XML code tokens for fair comparison with baseline methods.
Quick Start
Download Model Weights
First, install the Hugging Face CLI tool:
pip install huggingface-hub
Download the model from Hugging Face:
# Download OmniSVG1.1-8B
huggingface-cli download OmniSVG/OmniSVG1.1_8B --local-dir /PATH/TO/OmniSVG1.1_8B
# Download OmniSVG1.1-4B
huggingface-cli download OmniSVG/OmniSVG1.1_4B --local-dir /PATH/TO/OmniSVG1.1_4B
# Download OmniSVG-3B (legacy)
huggingface-cli download OmniSVG/OmniSVG --local-dir /PATH/TO/OmniSVG-3B
Text-to-SVG Generation
Basic usage - Generate SVG from txt file:
python inference.py --task text-to-svg --input prompts.txt --output ./output_text --save-all-candidates
Use 4B model:
python inference.py --task text-to-svg --input prompts.txt --output ./output_text --model-size 4B --save-all-candidates
Generate more candidates and save PNG:
python inference.py --task text-to-svg --input prompts.txt --output ./output_text \
--num-candidates 8 --save-png --save-all-candidates
Custom generation parameters:
python inference.py --task text-to-svg --input prompts.txt --output ./output_text \
--temperature 0.5 --top-p 0.9 --top-k 50 --repetition-penalty 1.05
Use local model:
python inference.py --task text-to-svg --input prompts.txt --output ./output_text \
--model-path /path/to/qwen --weight-path /path/to/omnisvg
Image-to-SVG Generation
python inference.py --task image-to-svg --input ./examples --output ./output_image --save-all-candidates
Interactive Demo
We provide an interactive generation interface using Gradio:
Local Deployment
python app.pyOnline Demo
Try our live demo on Hugging Face Spaces
5. License
OmniSVG is licensed under the Apache License 2.0, while MMSVG dataset is under Creative Commons Attribution Non Commercial Share Alike 4.0 License. You can find the license files in the respective github and HuggingFace repositories.
Citation
@article{yang2025omnisvg,
title={OmniSVG: A Unified Scalable Vector Graphics Generation Model},
author={Yiying Yang and Wei Cheng and Sijin Chen and Xianfang Zeng and Jiaxu Zhang and Liao Wang and Gang Yu and Xinjun Ma and Yu-Gang Jiang},
journal={arXiv preprint arxiv:2504.06263},
year={2025}
}
Acknowledgments
We thank the following excellent open-source works:
IconShop: is the first advanced work that leverages LLMs to generate monochrome, icon-level SVGs. We referred to its parametric implementation.
Here is the list of highly related concurrent works:
LLM4SVG: treats SVG coordinates as number strings and predicts decimal part for higher spatial accuracy.
StarVector: equips LLM with an image encoder for Image-to-SVG generation.
- Downloads last month
- -