m1357l/iconshop-svg-generator
IconShop SVG Icon Generator
⚠️ ALPHA / RESEARCH PREVIEW — NOT PRODUCTION READY This is alpha work. It is not production ready. This model is published as a starting point for people who want to get into the business of model training. The output quality is inconsistent, and you should expect broken or malformed SVGs. Treat this as an educational/demo artifact — not something to ship.
A custom autoregressive transformer model that generates SVG icons from text descriptions.
Example outputs
Model Description
This model is trained on the FIGR-8-SVG dataset using the IconShop architecture - an autoregressive transformer that predicts SVG vector commands token-by-token, conditioned on a text prompt.
Architecture:
- Transformer decoder with 16 layers, 8 attention heads
- Hidden dimension: 1024, Embedding dimension: 512
- BERT uncased tokenizer for text conditioning (50 token max)
- Pixel sequence length: 512
- SVG bounding box: 200x200
Training:
- Dataset: FIGR-8-SVG (1.5M cleaned SVG icons)
- 5 epochs on 4x NVIDIA RTX 3090
- Training loss: 2.01 (pixel loss: 2.17, text loss: 0.88)
Usage
Installation
pip install torch transformers safetensors deepsvg cairosvgGenerate SVGs from text
from huggingface_hub import hf_hub_download
import torch
from transformers import AutoTokenizer
# Download model files
model_path = hf_hub_download("m1357l/iconshop-svg-generator", "model.safetensors")
config_path = hf_hub_download("m1357l/iconshop-svg-generator", "config.json")
word_emb_path = hf_hub_download("m1357l/iconshop-svg-generator", "word_embedding_512.pt")
# Load model
from model.decoder import SketchDecoder
import json
with open(config_path) as f:
config = json.load(f)
tokenizer = AutoTokenizer.from_pretrained("google/bert_uncased_L-12_H-512_A-8")
model = SketchDecoder(
config={
'hidden_dim': config['hidden_dim'],
'embed_dim': config['embed_dim'],
'num_layers': config['num_layers'],
'num_heads': config['num_heads'],
'dropout_rate': config['dropout_rate'],
},
pix_len=config['pix_len'],
text_len=config['text_len'],
num_text_token=tokenizer.vocab_size,
word_emb_path=word_emb_path,
pos_emb_path=config['pos_emb_path'],
)
# Load weights
from safetensors.torch import load_file
state_dict = load_file(model_path)
model.load_state_dict(state_dict, strict=False)
model.eval()Command-line usage
# Single prompt
python model_card.py --output ./samples --prompts "star"
# Multiple prompts
python model_card.py --output ./samples --prompts "star" "calendar" "car"Limitations
- Generates icons in 200x200 bounding box
- Best results for simple, common icon types (arrows, stars, animals, UI elements)
- Complex scenes or abstract concepts may produce degraded output
- Trained on simplified SVG format (not all SVG features supported)
- Output quality varies significantly between samples
Repository
This model was trained using [michellacle/IconShop](https://github.com/michellacle/IconShop) — a fork of the original IconShop repository with training scripts, inference tools, and GPU setup for multi-GPU configurations. Check it out if you want to train your own IconShop model.
References
This model is based on the IconShop architecture and trained on the FIGR-8-SVG dataset. Please cite the original work if you use this model:
- IconShop: Ronghuan Wu, Wanchao Su, Kede Ma, Jing Liao. "IconShop: Text-Guided Vector Icon Synthesis with Autoregressive Transformers." ACM Transactions on Graphics (TOG), Vol. 42, No. 6, Article 230, December 2023. arXiv:2304.14400
- FIGR-8-SVG Dataset: Louis Clouâtre, Marc Demers. "FIGR: Few-shot Image Generation with Reptile." arXiv preprint arXiv:1901.02199, 2019. arXiv:1901.02199
License
CC BY-NC-SA 4.0 (Creative Commons Attribution-NonCommercial-ShareAlike 4.0)
This model is trained on the FIGR-8-SVG dataset, whose images are licensed under CC BY 3.0 (attribution required, commercial use prohibited). The original IconShop code repository has no explicit license. Therefore, this model is released under CC BY-NC-SA 4.0 to respect the original dataset's non-commercial terms.
- ✅ Attribution required — credit the original authors
- ✅ Share-alike — derivatives must use the same license
- ❌ Commercial use prohibited
