Running Unlimited-SVG in Production: Long Context, Missing Details, and SVG Security
Key engineering issues developers hit when deploying baidu/Unlimited-SVG in production, from transparent PNG preprocessing and temperature tuning to truncation recovery and XSS sanitization.

Getting baidu/Unlimited-SVG to emit its first <svg> locally takes only a few commands with vLLM or Hugging Face transformers. Turning it into a reliable online tool or automated API pipeline is a different story.
Across Hugging Face discussions, GitHub issue threads, and early deployment write-ups, developers consistently run into four practical engineering problems. Here is what causes each one and how we addressed them in our hosted pipeline.
1. Transparent PNGs and Wasted Vision Tokens
Unlimited-SVG uses a fixed 2048x2048 canvas compressed into 1,024 vision tokens and accepts a fixed <image> SVG: prompt format rather than free-form text instructions. That makes input preprocessing disproportionately important:
- Alpha channel pitfalls: If you drop a transparent PNG straight into an RGB converter without alpha compositing, transparent pixels frequently become solid black, causing dark marks or line art to disappear. Transparent assets should be composited onto a clean contrasting backdrop (white for dark artwork, or a neutral dark surface for white-only logos).
- Excess empty margins: Screenshots and exported icons often carry wide blank borders. Because the encoder allocates a fixed 1,024-token budget across the whole square, trimming excess margins before inference immediately dedicates more visual resolution to small labels, thin lines, and icons.
2. Temperature Sensitivity and Dropped Small Elements
One of the most frequent community observations is that single-pass sampling is sensitive to temperature:
- At
temperature = 0.0, the model stays geometrically disciplined on logos, wireframes, and CAD diagrams, yet occasionally skips a small corner symbol or enters a repetitive coordinate loop on denser art. - Higher temperatures (
0.5to0.8) break repetitive loops on natural illustrations, yet can soften straight technical lines if applied blindly. - Applying a global
repetition_penalty > 1.0on the first pass can unintentionally penalize legitimate repeated elements like bar-chart columns, sidebar list items, or grid dots.
In production, running concurrent multi-temperature candidates (for example [0.0, 0.15, 0.30, 0.50] in a single batched GPU pass) and ranking them by rendered visual accuracy against the input image solves most single-sample variance without asking end users to guess sampling parameters. When a localized region still has high residual error, zooming into that crop and re-vectorizing only the missing region under a strict visual acceptance gate recovers tiny elements that fall below the global 1,024-token ceiling.
Test the Production Pipeline Live
Below is our live Unlimited-SVG workbench running automatic margin trimming, concurrent Best-of-4 visual ranking, localized detail repair, seam healing, and strict XML validation behind a single upload button.
Upload a complex UI screenshot, floorplan, or emblem to inspect how multi-candidate selection and local repair perform.
Drop an image or click to upload
Paste with Cmd+V or choose PNG, JPG, WebP up to 10 MB
- Automatically adapts to logos, UI screens, illustrations, and technical drawings
- Runs Best-of-4 visual selection with targeted local detail repair
- Auto-trims margins and seals anti-aliasing seams for Figma-ready SVG output
No login required. Generate a watermarked preview first and pay only if you want the clean SVG.

3. Long-Context Truncation and Broken XML
Complex diagrams and multi-layer illustrations regularly cross 10,000 output tokens. If generation stops at a token ceiling before </svg> closes, browsers either fail to render the file or display a broken half-image.
A resilient serving layer should always:
- Allocate generous context headroom (
max_model_len = 32768,max_tokensup to30,000+). - Check both
finish_reasonand XML well-formedness (ElementTree/ strict XML parsing) after decoding. - Support assistant-prefix continuation when
finish_reason == "length", enabling a mild repetition penalty only if the trailing tail actually exhibits a loop.
4. Treating Model-Generated SVG as Untrusted Code
A point repeatedly emphasized in security reviews of Unlimited-SVG is that SVG is executable XML, not a passive bitmap. Any web app rendering model-generated SVG directly must assume the output could contain unsafe tags or attributes:
- Sanitize before storage or delivery: Strip
<script>,<foreignObject>,<iframe>, inlineon*event attributes (onload,onclick), andjavascript:URLs on the server. - Keep unpaid previews rasterized: In a pay-after-preview workflow, simply appending a
<g>watermark layer inside an SVG file is trivial to bypass in browser DevTools. Rendering unpaid previews server-side into a pixel-watermarked raster image (WebP/PNG) and keeping clean SVG markup strictly on the server until unlocked eliminates source leakage entirely.
Automating via REST API
If you want to integrate Unlimited-SVG into a design tool, build pipeline, or SaaS backend without provisioning your own GPU containers, our REST API documentation exposes the same production pipeline over a single authenticated endpoint:
curl -X POST "https://unlimited-svg.workers.dev/api/v1/image-to-svg" \
-H "Authorization: Bearer sk_live_your_api_key" \
-F "file=@wireframe.png" \
-F "detail_level=ultra" \
-F "response_format=json"
Whether you self-host the MIT weights with vLLM or call a hosted API, paying attention to preprocessing, multi-candidate visual ranking, continuation guards, and SVG sanitization is what separates a neat demo from production-grade vectorization.