How to Run Baidu Unlimited-SVG Locally: Image to Editable SVG on a 12 GB GPU

2026-12-02来源 dev.toEnglish

Baidu's Unlimited-SVG converts a PNG or JPG into editable SVG source: layers, paths, and text as real <text> elements. Potrace and VTracer trace pixel edges; this one writes the SVG the way a language model writes code. It's MIT-licensed, 3.3B parameters with about 0.5B active per token, and it passed 400 likes on Hugging Face within a week. The release doesn't include a single benchmark number.

So nobody can tell you from the published material whether it replaces the paid vectorizer you use today. If you have an NVIDIA card you can find out yourself, and by my math from the config a 12 GB one should be enough. I'll go through what the model is, how much VRAM I think it needs, the exact transformers and vLLM commands, and the eval() in its remote code that someone already flagged.

What Unlimited-SVG actually is

From the model card, the config.json and the project blog:

Spec Value
Base model DeepSeek-OCR (DeepEncoder + DeepSeek-V2 MoE decoder)
Total parameters 3,336,106,240 (BF16)
Active per token ~0.5B (64 routed experts, 6 picked per token, 2 shared)
Weights on disk one ~6.7 GB safetensors file
Input 2048 × 2048 image compressed to 1024 vision tokens
Max context 32,768 tokens
License MIT (weights and code)
Authors Baidu ERNIE, Multimodal Team
Pipeline tag image-text-to-text, trust_remote_code required

The architecture choice makes sense once you look at output length. Baidu says a complete SVG for a complex image "often exceeds 10,000 tokens". Running a dense 30B model for 10k tokens per image is slow and expensive. They kept the visual prefix small (DeepSeek-OCR's encoder squeezes 2048² pixels into 1024 tokens) and kept decoding cheap with sparse experts. The DeepSeek-OCR paper is where that encoder comes from, and Unlimited-SVG's config still lists DeepseekOCRForCausalLM in its architectures.

The prompt is just <image> SVG:. There's no chat interface, so you can't tell it "make the stroke 2px" and expect it to listen; you give it an image and get SVG back.

What Baidu claims, and what's missing

The claims on the project page are all qualitative:

  • it tracks "the exact position of every element in crowded scenes", including small text and thin strokes
  • it separates foreground from background and rebuilds the scene "layer by layer in a clean, logical order"
  • it brings to a 0.5B-active model what "has so far been within reach only of frontier models (e.g. GPT-6.2 Astra, Fable 5.2, Gemini 4 Argon)"
  • it "sustains real-time generation well past 10,000 tokens"

There's no comparison table against those frontier models, and none against classic vectorizers like Potrace, VTracer or Vectorizer.AI either. The release has no SSIM, LPIPS, path counts, file sizes or tokens per second on named hardware. The blog says "Technical report coming soon."

The model might well be good. The case-study GIF and the hosted demo are impressive, and a demo you can feed your own images is worth more than a cherry-picked table. But "real-time" with no GPU named is a claim you can't check, and if someone on your team asks whether this beats the tool you pay for, the honest answer right now is "test it on our assets".

One thing I'd expect to matter for frontend work: a traced SVG from VTracer is a stack of filled paths. An SVG written by a language model can contain text, groups and z-ordered shapes, which is the whole pitch. It also means the output can be wrong in ways a tracer never is, like a misread word in a <text> node or a hallucinated shape behind an occluded object.

VRAM: what you'll need to run it locally

The card doesn't give a VRAM number. It asks for "x86-64 Linux with uv, a compatible NVIDIA driver, and a free BF16-capable GPU." Here's my back-of-envelope estimate from the config. I haven't measured any of this.

  • Weights: 3.34B params × 2 bytes ≈ 6.7 GB
  • KV cache: 12 layers × 2 (K and V) × 1280 hidden × 2 bytes ≈ 60 KB per token, so roughly 1.8 GB for a 30,000-token generation
  • Plus activations, the vision encoder pass and CUDA overhead

So a 12 GB card looks plausible for single-image inference, 16 GB is comfortable, and 8 GB is probably out unless someone quantizes it. The official vLLM command uses --gpu-memory-utilization 0.8, which on a 24 GB card is about 19 GB reserved. That's vLLM pre-allocating cache, not a minimum requirement.

No official Mac or CPU path is documented. If you're on Apple Silicon, use the official Space or AK's ZeroGPU Space.

How to run Unlimited-SVG with transformers

This comes straight from the model card. Look at the version pins: transformers==4.46.3 and torch==2.6.0 are old, so give it its own venv.

uv venv .venv-svg-hf --python 3.12 uv pip install --python .venv-svg-hf/bin/python \ torch==2.6.0 torchvision==0.21.0 transformers==4.46.3 tokenizers==0.20.3 \ safetensors==0.8.0 pillow==13.0.0 einops==0.8.2 addict==2.4.0 \ easydict==1.14 accelerate==1.16.0 requests==2.34.2 \ huggingface_hub==0.36.0 

Copy infer_hf.py from the model card, then:

CUDA_VISIBLE_DEVICES=0 .venv-svg-hf/bin/python infer_hf.py /path/to/image.png 

The script pads your image onto a gray 2048 × 2048 canvas, composites alpha onto white (so transparent PNGs don't come out black), generates up to max_new_tokens=30000 greedily, pulls out the <svg>...</svg> block, checks it parses as XML, and writes output.svg. If generation stops before </svg>, you get an Incomplete SVG error and the raw text in output.txt.

The setting worth changing is temperature. The card recommends 0–0.3 for CAD, diagrams and charts, and 0.5–0.8 for photos "to avoid repetitive loops". The example forces do_sample=False, so for photos you need to edit the generate wrapper and pass do_sample=True with a temperature.

How to run Unlimited-SVG with vLLM (and the site-packages patch)

The vLLM path is faster for batches, but the setup is hacky. The card pins vllm==0.33.0 with torch==2.14.0, and then has you patch vLLM's installed source with a regex so the DeepSeek-OCR processor uses 2048 instead of its defaults:

for name, value in {"BASE_SIZE": 2048, "IMAGE_SIZE": 2048, "CROP_MODE": False}.items(): source, count = re.subn(rf"^{name} = .+$", f"{name} = {value}", source, flags=re.M) 

That edits vllm/transformers_utils/processors/deepseek_ocr.py inside site-packages. It works, but it'll silently break other DeepSeek-OCR workloads in the same venv, and a pip install -U will undo it. Keep this venv dedicated. The server command:

VLLM_CUDNN_LIB="$PWD/.venv-svg-vllm/lib/python3.12/site-packages/nvidia/cudnn/lib" LD_LIBRARY_PATH="$VLLM_CUDNN_LIB${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" \ CUDA_VISIBLE_DEVICES=0 VLLM_USE_V2_MODEL_RUNNER=0 TRITON_ALLOW_NON_CONSTEXPR_GLOBALS=1 \ .venv-svg-vllm/bin/vllm serve baidu/Unlimited-SVG \ --served-model-name Unlimited-SVG --trust-remote-code \ --no-enable-prefix-caching --mm-processor-cache-gb 0 \ --limit-mm-per-prompt '{"image":1}' --max-model-len 32768 --max-num-seqs 1 \ --gpu-memory-utilization 0.8 \ --compilation-config '{"cudagraph_mode":"FULL_DECODE_ONLY","cudagraph_capture_sizes":[1,2,4,8]}' \ --host 127.0.0.1 --port 10000 

Then you send an OpenAI-style request with the image as a base64 data URL and the text <image> SVG:. Note --max-num-seqs 1: the reference setup handles one image at a time.

If you live in ComfyUI, a community member already published a node pack with converted weights, linked from this discussion.

About that eval() in the remote code

Someone opened a discussion because modeling_unlimitedsvg.py calls Python's eval() on model output, and you have to load it with trust_remote_code=True. That's a fair thing to flag. I read the file: the eval() calls sit in the save_results branch of infer(), which looks inherited from DeepSeek-OCR's geometry and line-drawing output. The official example passes eval_mode=True and leaves save_results off, so that path doesn't run. I'd still pin the repo revision (sha b639846... at the time of writing) before running remote code from any org in production.

Unlimited-SVG vs VTracer: where I'd actually use it

For flat icons and logos, I'd run the same files through VTracer (free and fast) and through this, then compare path count and how the files look at 16px. For diagrams, screenshots with text, and illustrations where you'd actually want to edit layers afterward, this is the open-weights model I'd test first. Treat every output as a draft either way; even the reference script has to check for truncated SVGs.

Would you ship model-generated SVG icons straight to production, or does the path code always need a pass in Figma or by hand first? If you've already run it on real design-system assets, I'd like to see your numbers.

Sources

原文:https://www.a8q9.cn/en/article/how-to-run-baidu-unlimited-svg-locally-image-to-editable-svg-on-a-12-gb-gpu-11d4f9.html

相关文章