MCPcopy Index your code
hub / github.com/SagiPolaczek/NeuralSVG

github.com/SagiPolaczek/NeuralSVG @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
252 symbols 793 edges 32 files 170 documented · 67%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

NeuralSVG: An Implicit Representation for Text-to-Vector Generation

NeuralSVG generates vector graphics from text prompts with ordered and editable shapes. Our method supports dynamic conditioning, such as background color, which facilitating the generation of multiple color palettes for a single learned representation.

Sagi Polaczek, Yuval Alaluf, Elad Richardson, Yael Vinker, Daniel Cohen-Or

Vector graphics are essential in design, providing artists with a versatile medium for creating resolution-independent and highly editable visual content. Recent advancements in vision-language and diffusion models have fueled interest in text-to-vector graphics generation. However, existing approaches often suffer from over-parameterized outputs or treat the layered structure --- a core feature of vector graphics --- as a secondary goal, diminishing their practical use. Recognizing the importance of layered SVG representations, we propose NeuralSVG, an implicit neural representation for generating vector graphics from text prompts. Inspired by Neural Radiance Fields (NeRFs), NeuralSVG encodes the entire scene into the weights of a small MLP network, optimized using Score Distillation Sampling (SDS). To encourage a layered structure in the generated SVG, we introduce a dropout-based regularization technique that strengthens the standalone meaning of each shape. We additionally demonstrate that utilizing a neural representation provides an added benefit of inference-time control, enabling users to dynamically adapt the generated SVG based on user-provided inputs, all with a single learned representation. Through extensive qualitative and quantitative evaluations, we demonstrate that NeuralSVG outperforms existing methods in generating structured and flexible SVG.

🔥 NEWS

2025/08/01: See you in ICCV 2025 🍻!

2025/04/17: Our code is released!

2025/01/07: Paper is out!

Table of Contents

Examples

Here are some example outputs:

Installation

Step 0 - Create a new conda env

conda create -n neuralsvg_env python=3.10 -y
conda activate neuralsvg_env

Step 1 - Install diffvg

Please follow their installation guide. It might get tricky! be patient :-)

Step 2 - Install requirements

pip install -r requirements.txt

Step 3 - Download LoRAs

# Make sure you are in the correct directory
cd ./lora_weights/

# Download using HF's CLI
huggingface-cli download SagiPolaczek/SD2.1-NeuralSVG-LoRAs lora_weights_sd21b_bg_color.safetensors lora_weights_sd21b_bg_color_colorful.safetensors lora_weights_sd21b_sketches.safetensors --local-dir .

Usage

Tips

  • Use simple prompts - clear scene and few objects.
  • Seed - Different seeds results with different outcomes. Moreover, since we don't have control on diffvg's randomness, we can't reproduce runs.

Color Control

# Sunflower
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist vector art of a sunflower" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color.safetensors" --log.exp_name='neuralsvg_sunflower'

# Baby penguin
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist vector art of a baby penguin" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color.safetensors" --log.exp_name='neuralsvg_baby_penguin'

# Baby bunny sitting on a stack of pancakes
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist vector art of a baby bunny sitting on a stack of pancakes" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color.safetensors" --log.exp_name='neuralsvg_bunny_pancakes'

# Dog
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist vector art of a dog" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color.safetensors" --log.exp_name='neuralsvg_dog'

You can enhance the color difference by using a different LoRA with slightly different prompt. For example:

# Colorful Sydney Opera House
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist colorful vector art of Sydney Opera House" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color_colorful.safetensors" --log.exp_name='neuralsvg_sydney'

# Colorful Dog with a hat
python scripts/train.py --config_path config_files/run_shaping.yaml --data.text_prompt="minimalist colorful vector art of a cat with a hat" --model.toggle_color="true" --model.toggle_color_bg_colors="['light-red', 'light-green', 'light-blue', 'gold', 'gray']" --model.lora_weights="./lora_weights/lora_weights_sd21b_bg_color_colorful.safetensors" --log.exp_name='neuralsvg_cat_with_hat'

Aspect Ratio Control

TBD

Sketches

# Rose
python scripts/train.py --config_path config_files/run_sketching.yaml --data.text_prompt="minimal 2d line drawing of a rose. on a white background."

# Flamingo
python scripts/train.py --config_path config_files/run_sketching.yaml --data.text_prompt="minimal 2d line drawing of a flamingo. on a white background."

Inference

A cool use-case for our implicit representation is that we can load the model, post-training, and use it to infer unlimited amount of background colors, hopefully resulting with different coloring.

A detailed script will be published!

Citation

If you find this code useful for your research, please consider citing us:

@misc{polaczek2025neuralsvgimplicitrepresentationtexttovector,
      title={NeuralSVG: An Implicit Representation for Text-to-Vector Generation}, 
      author={Sagi Polaczek and Yuval Alaluf and Elad Richardson and Yael Vinker and Daniel Cohen-Or},
      year={2025},
      eprint={2501.03992},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2501.03992}, 
}

Star History

Star History Chart

Core symbols most depended-on inside this repo

get_image
called by 15
src/models/painter.py
tensor2im
called by 12
src/training/utils/vis_utils.py
save_svg
called by 7
src/models/painter.py
log_message
called by 5
src/training/logging/coach_logger.py
forward
called by 5
src/models/nerf_mlp_multi.py
_make_layer
called by 4
CLIP_/clip/model.py
encode
called by 3
CLIP_/clip/simple_tokenizer.py
multi_head_attention_forward
called by 3
CLIP_/clip/auxilary.py

Shape

Method 169
Function 47
Class 36

Languages

Python100%

Modules by API surface

src/training/coach.py40 symbols
CLIP_/clip/model.py39 symbols
src/models/nerf_mlp_multi.py33 symbols
src/models/painter.py20 symbols
src/models/painter_nerf.py18 symbols
src/training/logging/coach_logger.py13 symbols
CLIP_/clip/simple_tokenizer.py10 symbols
src/configs/train_config.py9 symbols
src/training/losses.py8 symbols
src/models/attention_utils.py8 symbols
CLIP_/clip/auxilary.py8 symbols
src/training/utils/vis_utils.py7 symbols

For agents

$ claude mcp add NeuralSVG \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact