{"slug": "unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything", "title": "Unlimited SVG: Trace On – Projection of Visual Worlds into SVG-Anything", "summary": "Baidu released Unlimited-SVG, a multimodal model built on DeepSeek-OCR that redraws any image as a structured, editable SVG while activating only about 0.5B parameters per token. Unlimited-SVG's DeepEncoder compresses a 2048 × 2048 image into 1024 vision tokens, and its mixture-of-experts decoding sustains real-time generation past 10,000 tokens, the length a complex SVG can require. The model is available on Hugging Face as baidu/Unlimited-SVG and on ModelScope, and runs locally on a BF16-capable NVIDIA GPU with greedy decoding by default.", "body_md": "- [2026/12/01] 🤝 Thanks to the [ModelScope community](https://github.com/modelscope) for their support. Our model is now available at[ModelScope](https://modelscope.cn/models/baidu/Unlimited-SVG) .\n- [2026/12/01] 🚀 We present [Unlimited-SVG](https://github.com/baidu/Unlimited-SVG/) , a multimodal model that redraws any image as a structured, editable SVG using just 0.5B activated parameters.\n\nGenerating a complete SVG for a complex image often exceeds 10,000 tokens—a long-context regime where large models quickly become slow and prohibitive. Built on DeepSeek-OCR, Unlimited SVG breaks this bottleneck from both ends.\n\nOn the input side, DeepEncoder compresses an entire 2048 × 2048 image into just 1024 vision tokens while preserving fine details such as small text, thin strokes, and exact spatial coordinates—dramatically shrinking the visual prefix before decoding even begins.\n\nOn the decoding side, its mixture-of-experts (MoE) architecture activates only ~0.5B parameters per token. Minimal visual prefix meets sparse active compute: Unlimited SVG sustains real-time generation well past 10,000 tokens—making long-horizon, complex SVG conversion practical on a compact, locally deployable model rather than relying on heavy frontier APIs like GPT-6.2 Astra and Claude Fable 5.2.\n\nRun from the repository root on x86-64 Linux with `uv`, a compatible NVIDIA\ndriver, and a free BF16-capable GPU. Use the Hugging Face model `baidu/Unlimited-SVG`, which supports\n2048 × 2048 global inference. Both examples use `ImageOps.pad` to resize\nthe long edge to 2048 pixels while preserving the aspect ratio, then center\nthe image on a gray **2048 × 2048** canvas without tiling. Transparent pixels\nare composited onto white first, so images with alpha do not turn black.\n\nBoth examples run greedily by default (`do_sample=False` in Transformers,\n`temperature=0` in vLLM) for deterministic output. Tune the sampling\ntemperature to the image type:\n\n- **CAD, diagrams, charts, and other images that need exact detail\nconsistency** : keep the temperature low (e.g.,`0–0.3` ) to preserve\nprecise geometry and text.\n- **Natural scenes and photos** : raise the temperature (e.g.,`0.5–0.8` ) to\navoid repetitive loops and encourage more varied strokes.\n\nTo sample with Transformers, pass `do_sample=True` and a `temperature`\ninstead of the greedy override above; with vLLM, set `temperature` in the\nrequest.\n\nInstall dependencies.\n\n```\nuv venv .venv-svg-hf --python 3.12\nuv pip install --python .venv-svg-hf/bin/python \\\n  torch==2.6.0 torchvision==0.21.0 transformers==4.46.3 tokenizers==0.20.3 \\\n  safetensors==0.8.0 pillow==13.0.0 einops==0.8.2 addict==2.4.0 \\\n  easydict==1.14 accelerate==1.16.0 requests==2.34.2 \\\n  huggingface_hub==0.36.0\n```\n\nSave the following code as `infer_hf.py`.\n\n``` python\nimport re\nimport sys\nfrom pathlib import Path\nfrom tempfile import TemporaryDirectory\nfrom xml.etree import ElementTree\n\nimport torch\nfrom PIL import Image, ImageOps\nfrom huggingface_hub import snapshot_download\nfrom safetensors import safe_open\nfrom safetensors.torch import load_file\nfrom transformers import AutoModel, AutoTokenizer\n\nmodel_name = \"baidu/Unlimited-SVG\"\nimage_path = sys.argv[1]\n\ndef flatten_alpha(image):\n    \"\"\"Composite transparent pixels onto white so they do not turn black.\"\"\"\n    if image.mode not in (\"RGBA\", \"LA\", \"PA\") and \"transparency\" not in image.info:\n        return image.convert(\"RGB\")\n    rgba = image.convert(\"RGBA\")\n    white = Image.new(\"RGB\", rgba.size, (255, 255, 255))\n    white.paste(rgba, mask=rgba.getchannel(\"A\"))\n    return white\n\nmodel_path = snapshot_download(model_name)\ntokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)\noptions = {\"low_cpu_mem_usage\": True}\nweights = list(Path(model_path).glob(\"model*.safetensors\"))\nif len(weights) == 1:\n    with safe_open(weights[0], framework=\"pt\", device=\"cpu\") as shard:\n        metadata = shard.metadata()\n    if metadata is None:\n        options = {\"low_cpu_mem_usage\": False, \"state_dict\": load_file(weights[0])}\n\nmodel = AutoModel.from_pretrained(\n    model_path, trust_remote_code=True, use_safetensors=True,\n    torch_dtype=torch.bfloat16, attn_implementation=\"eager\", **options,\n).eval().cuda()\noriginal_generate = model.generate\n\ndef generate(*args, **kwargs):\n    kwargs.pop(\"temperature\", None)\n    kwargs.update(max_new_tokens=30000, no_repeat_ngram_size=0,\n                  do_sample=False, repetition_penalty=1)\n    return original_generate(*args, **kwargs)\n\nmodel.generate = generate\nwith TemporaryDirectory() as directory:\n    prepared = Path(directory) / \"input.png\"\n    with Image.open(image_path) as image:\n        ImageOps.pad(\n            flatten_alpha(ImageOps.exif_transpose(image)), (2048, 2048),\n            method=Image.Resampling.BICUBIC, color=(127, 127, 127),\n        ).save(prepared)\n    with torch.inference_mode():\n        raw = model.infer(\n            tokenizer, prompt=\"<image> SVG:\", image_file=str(prepared),\n            output_path=directory, base_size=2048, image_size=2048,\n            crop_mode=False, eval_mode=True,\n        )\n\nPath(\"output.txt\").write_text(raw, encoding=\"utf-8\")\nmatch = re.search(r\"<svg\\b.*?</svg>\", raw, re.DOTALL)\nif match is None:\n    raise RuntimeError(\"Incomplete SVG. See output.txt.\")\nsvg = match.group()\nElementTree.fromstring(svg)\nPath(\"output.svg\").write_text(svg, encoding=\"utf-8\")\nCUDA_VISIBLE_DEVICES=0 .venv-svg-hf/bin/python infer_hf.py /path/to/image.png\n```\n\nThe first run downloads the model weights from Hugging Face and stores them in the local Hugging Face cache. Subsequent runs reuse the cached files.\n\nInstall dependencies.\n\n```\nuv venv .venv-svg-vllm --python 3.12\nuv pip install --python .venv-svg-vllm/bin/python \\\n  vllm==0.33.0 torch==2.14.0 nvidia-cudnn-cu13==9.24.0.43 \\\n  openai==3.60.0 pillow==13.0.0\n```\n\nSet the server image processor to 2048 × 2048 without tiling.\n\n``` python\n.venv-svg-vllm/bin/python - <<'PY'\nimport re\nimport sysconfig\nfrom pathlib import Path\n\npath = Path(sysconfig.get_path(\"purelib\")) / \"vllm/transformers_utils/processors/deepseek_ocr.py\"\nsource = path.read_text()\nfor name, value in {\"BASE_SIZE\": 2048, \"IMAGE_SIZE\": 2048, \"CROP_MODE\": False}.items():\n    source, count = re.subn(rf\"^{name} = .+$\", f\"{name} = {value}\", source, flags=re.M)\n    if count != 1:\n        raise RuntimeError(f\"Cannot configure {name}\")\ntemporary = path.with_suffix(\".py.tmp\")\ntemporary.write_text(source)\ntemporary.replace(path)\nPY\n```\n\nStart the server in a terminal.\n\n```\nVLLM_CUDNN_LIB=\"$PWD/.venv-svg-vllm/lib/python3.12/site-packages/nvidia/cudnn/lib\"\nLD_LIBRARY_PATH=\"$VLLM_CUDNN_LIB${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}\" \\\n  CUDA_VISIBLE_DEVICES=0 VLLM_USE_V2_MODEL_RUNNER=0 TRITON_ALLOW_NON_CONSTEXPR_GLOBALS=1 \\\n  .venv-svg-vllm/bin/vllm serve baidu/Unlimited-SVG \\\n  --served-model-name Unlimited-SVG --trust-remote-code \\\n  --no-enable-prefix-caching --mm-processor-cache-gb 0 \\\n  --limit-mm-per-prompt '{\"image\":1}' --max-model-len 32768 --max-num-seqs 1 \\\n  --gpu-memory-utilization 0.8 \\\n  --compilation-config '{\"cudagraph_mode\":\"FULL_DECODE_ONLY\",\"cudagraph_capture_sizes\":[1,2,4,8]}' \\\n  --host 127.0.0.1 --port 10000\n```\n\nSave the following code as `infer_vllm.py`.\n\n``` python\nimport base64\nimport io\nimport re\nimport sys\nfrom pathlib import Path\nfrom xml.etree import ElementTree\n\nfrom openai import OpenAI\nfrom PIL import Image, ImageOps\n\ndef flatten_alpha(image):\n    \"\"\"Composite transparent pixels onto white so they do not turn black.\"\"\"\n    if image.mode not in (\"RGBA\", \"LA\", \"PA\") and \"transparency\" not in image.info:\n        return image.convert(\"RGB\")\n    rgba = image.convert(\"RGBA\")\n    white = Image.new(\"RGB\", rgba.size, (255, 255, 255))\n    white.paste(rgba, mask=rgba.getchannel(\"A\"))\n    return white\n\nbuffer = io.BytesIO()\nwith Image.open(sys.argv[1]) as image:\n    ImageOps.pad(\n        flatten_alpha(ImageOps.exif_transpose(image)), (2048, 2048),\n        method=Image.Resampling.BICUBIC, color=(127, 127, 127),\n    ).save(buffer, format=\"PNG\")\nurl = \"data:image/png;base64,\" + base64.b64encode(buffer.getvalue()).decode(\"ascii\")\nclient = OpenAI(base_url=\"http://127.0.0.1:10000/v1\", api_key=\"EMPTY\", timeout=6000)\nraw_path = Path(\"output-vllm.txt\")\nwith client.chat.completions.create(\n    model=\"Unlimited-SVG\",\n    messages=[{\"role\": \"user\", \"content\": [\n        {\"type\": \"image_url\", \"image_url\": {\"url\": url}},\n        {\"type\": \"text\", \"text\": \"<image> SVG:\"},\n    ]}],\n    temperature=0, top_p=1, max_tokens=30000, stream=True,\n    extra_body={\"top_k\": 0, \"repetition_penalty\": 1},\n) as stream, raw_path.open(\"w\", encoding=\"utf-8\") as output:\n    for chunk in stream:\n        if chunk.choices:\n            output.write(chunk.choices[0].delta.content or \"\")\n\nmatch = re.search(r\"<svg\\b.*?</svg>\", raw_path.read_text(encoding=\"utf-8\"), re.DOTALL)\nif match is None:\n    raise RuntimeError(\"Incomplete SVG. See output-vllm.txt.\")\nsvg = match.group()\nElementTree.fromstring(svg)\nPath(\"output-vllm.svg\").write_text(svg, encoding=\"utf-8\")\n```\n\nRun inference in a second terminal once the server is ready.\n\n```\n.venv-svg-vllm/bin/python infer_vllm.py /path/to/image.png\n@misc{unlimitedsvg2026,\n  title  = {Unlimited SVG Works: Trace On -- Projection of Visual Worlds into SVG-Anything},\n  author = {Baidu ERNIE, Multimodal Team},\n  year   = {2026},\n  url    = {https://unlimited-svg.github.io/}\n}\n```\n\n", "url": "https://wpnews.pro/news/unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything", "canonical_source": "https://github.com/baidu/Unlimited-SVG/", "published_at": "2026-12-01 06:36:26+00:00", "updated_at": "2026-12-01 06:46:06.910230+00:00", "lang": "en", "topics": ["artificial-intelligence", "generative-ai", "computer-vision", "ai-research", "ai-tools"], "entities": ["Baidu", "Unlimited-SVG", "DeepSeek-OCR", "DeepEncoder", "Hugging Face", "ModelScope", "vLLM", "Transformers"], "also_reported_by": [], "takeaway": "Unlimited-SVG compresses a 2048 × 2048 image into 1024 vision tokens and activates ~0.5B parameters per token, letting a locally deployable model generate SVGs beyond 10,000 tokens; keep temperature at 0–0.3 for CAD, diagrams and charts and 0.5–0.8 for natural scenes and photos.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything", "markdown": "https://wpnews.pro/news/unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything.md", "text": "https://wpnews.pro/news/unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything.txt", "jsonld": "https://wpnews.pro/news/unlimited-svg-trace-on-projection-of-visual-worlds-into-svg-anything.jsonld"}}