đ SVGDreamer
SVGDreamer is an advanced text - to - SVG generation model. It uses a multi - particle optimization approach to create high - quality vector graphics, generating multiple SVG variants simultaneously for diverse and creative outputs.
đ Quick Start
SVGDreamer offers two ways to generate SVG images. You can either make a direct API call or use the Inference Client.
Direct API Call
import requests
API_URL = "https://api-inference.huggingface.co/models/jree423/svgdreamer"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": "a majestic eagle soaring through clouds",
"parameters": {
"n_particle": 6,
"num_iter": 1000,
"guidance_scale": 7.5,
"style": "iconography",
"width": 224,
"height": 224,
"seed": 42
}
})
Using the Inference Client
from huggingface_hub import InferenceClient
client = InferenceClient("jree423/svgdreamer")
result = client.post(
json={
"inputs": "a cyberpunk cityscape at night",
"parameters": {
"n_particle": 4,
"style": "pixel_art",
"guidance_scale": 8.0
}
}
)
⨠Features
- Multi - Particle Generation: Simultaneously creates multiple SVG variants.
- Style Control: Supports various artistic styles such as iconography, pixel art, sketch, and painting.
- High Quality: Produces detailed and aesthetically pleasing vector graphics.
- Flexible Parameters: Provides extensive customization options for fine - tuning the output.
đĻ Installation
No installation steps are provided in the original document, so this section is skipped.
đģ Usage Examples
Basic Usage
The basic usage examples are shown in the "Quick Start" section above, including direct API call and using the Inference Client.
Advanced Usage
You can adjust the parameters according to your specific needs. For example, increasing the num_iter
parameter can improve the quality of the generated SVG, but it will also take longer.
import requests
API_URL = "https://api-inference.huggingface.co/models/jree423/svgdreamer"
headers = {"Authorization": "Bearer YOUR_HF_TOKEN"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
output = query({
"inputs": "a beautiful castle in the mountains",
"parameters": {
"n_particle": 8,
"num_iter": 2000,
"guidance_scale": 8.5,
"style": "painting",
"width": 448,
"height": 448,
"seed": 123
}
})
đ Documentation
Parameters
Property |
Details |
n_particle |
Number of SVG particles to generate. Each particle represents a different interpretation of the prompt. Default is 6. |
num_iter |
Number of optimization iterations. More iterations improve quality but take longer. Default is 1000. |
guidance_scale |
Controls how closely the generation follows the text prompt. Default is 7.5. |
width |
Output SVG width in pixels. Default is 224. |
height |
Output SVG height in pixels. Default is 224. |
seed |
Random seed for reproducible results. Default is 42. |
style |
Style of the generated SVG. Options are "iconography", "pixel_art", "sketch", "painting". Default is "iconography". |
Output Format
The model returns a list of JSON objects, one for each particle, containing:
particle_id
: Unique identifier for the particle
svg
: The generated SVG content as a string
svg_base64
: Base64 encoded SVG for easy transmission
prompt
: The input text prompt
style
: The style used for generation
parameters
: The parameters used for generation
Styles
- Iconography: Clean, minimalist vector graphics suitable for icons and logos. Example: "a simple house icon".
- Pixel Art: Retro - style graphics with pixelated aesthetics. Example: "a pixel art character".
- Sketch: Hand - drawn style with organic lines and artistic flair. Example: "a sketch of a mountain landscape".
- Painting: Rich, painterly style with complex color gradients. Example: "an oil painting of a sunset".
Examples
- Nature Scenes: "a forest with tall pine trees", "ocean waves crashing on rocks", "a field of sunflowers under blue sky".
- Characters and Objects: "a friendly robot character", "a vintage bicycle", "a magical wizard casting spells".
- Abstract Art: "geometric patterns in bright colors", "flowing organic shapes", "mandala design with intricate details".
đ§ Technical Details
- Base Model: Stable Diffusion 2.1
- Framework: PyTorch + Diffusers
- Vector Rendering: DiffVG (differentiable vector graphics)
- Optimization: Multi - particle VPSD (Vector Particle - based Score Distillation)
- Parallel Processing: Simultaneous optimization of multiple SVG representations
đ License
This model is released under the MIT License.
Citation
@inproceedings{xing2024svgdreamer,
title={SVGDreamer: Text Guided SVG Generation with Diffusion Model},
author={Xing, XiMing and others},
booktitle={CVPR},
year={2024}
}