Instructions to use JosefKuchar/svg-generator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use JosefKuchar/svg-generator with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("Tongyi-MAI/Z-Image", dtype=torch.bfloat16, device_map="cuda") pipe.load_lora_weights("JosefKuchar/svg-generator") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
Upload README.md
Browse files
README.md
CHANGED
|
@@ -10,16 +10,16 @@ tags:
|
|
| 10 |
- text-to-image
|
| 11 |
- svg
|
| 12 |
- vector-graphics
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
# SVG Generator
|
| 16 |
|
| 17 |
This repository contains models for a two-stage text-to-SVG generation pipeline.
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
The vectorization model will be added as a separate component in the same
|
| 22 |
-
repository.
|
| 23 |
|
| 24 |
## Z-Image SVG LoRA
|
| 25 |
|
|
@@ -77,3 +77,45 @@ SVG illustration with white background.
|
|
| 77 |
This is only the bitmap-generation stage of the full pipeline. The output of
|
| 78 |
the LoRA is still a raster image and must be converted to SVG by a separate
|
| 79 |
vectorization model or tool.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
- text-to-image
|
| 11 |
- svg
|
| 12 |
- vector-graphics
|
| 13 |
+
- image-to-vector
|
| 14 |
+
- flow-matching
|
| 15 |
---
|
| 16 |
|
| 17 |
# SVG Generator
|
| 18 |
|
| 19 |
This repository contains models for a two-stage text-to-SVG generation pipeline.
|
| 20 |
+
It includes a LoRA adapter for Z-Image that biases image generation toward clean
|
| 21 |
+
SVG-style illustrations and a flow-matching vectorizer that converts raster
|
| 22 |
+
images into Bezier-curve SVGs.
|
|
|
|
|
|
|
| 23 |
|
| 24 |
## Z-Image SVG LoRA
|
| 25 |
|
|
|
|
| 77 |
This is only the bitmap-generation stage of the full pipeline. The output of
|
| 78 |
the LoRA is still a raster image and must be converted to SVG by a separate
|
| 79 |
vectorization model or tool.
|
| 80 |
+
|
| 81 |
+
## Flow-Matching Vectorizer
|
| 82 |
+
|
| 83 |
+
Vectorizer files:
|
| 84 |
+
|
| 85 |
+
- `flow-matching/config.json`
|
| 86 |
+
- `flow-matching/model.safetensors`
|
| 87 |
+
|
| 88 |
+
The vectorizer is conditioned on DINOv3 image features from
|
| 89 |
+
`facebook/dinov3-vits16-pretrain-lvd1689m`. The DINOv3 encoder is not stored in
|
| 90 |
+
this repository; it is loaded separately from its original Hugging Face
|
| 91 |
+
repository.
|
| 92 |
+
|
| 93 |
+
The model can be loaded from the Hub with the helper code in this repository:
|
| 94 |
+
|
| 95 |
+
```python
|
| 96 |
+
import torch
|
| 97 |
+
from flow_matching_hf import load_dino_encoder, load_flow_matching_from_hub
|
| 98 |
+
|
| 99 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 100 |
+
|
| 101 |
+
vectorizer = load_flow_matching_from_hub(
|
| 102 |
+
"JosefKuchar/svg-generator",
|
| 103 |
+
subfolder="flow-matching",
|
| 104 |
+
device=device,
|
| 105 |
+
)
|
| 106 |
+
processor, image_encoder = load_dino_encoder(device=device)
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
For folder-based PNG to SVG inference:
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
uv run python vectorize_png_folder_model.py ./pngs ./svgs \
|
| 113 |
+
--model-repo-id JosefKuchar/svg-generator \
|
| 114 |
+
--batch-size 1 \
|
| 115 |
+
--steps 50 \
|
| 116 |
+
--max-segments 256
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
The exported vectorizer was created from the original PyTorch Lightning
|
| 120 |
+
checkpoint by removing the frozen DINOv3 encoder tensors and trainer state. The
|
| 121 |
+
original checkpoint is not required for inference.
|