File size: 3,382 Bytes
4d6c088
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
license: apache-2.0
library_name: pytorch
tags:
- svg
- computer-vision
- autoencoder
- representation-learning
- arxiv:2608.21893
---

# SLS — A Scalable Vector Graphics Latent Space

Pretrained weights and tokenizer for **A Scalable Vector Graphics Latent Space** (ECCV 2026).

- **Authors:** Leonardo Zini, Elia Frigieri, Lorenzo Baraldi
- **Paper:** https://arxiv.org/abs/2608.21893
- **Code:** https://github.com/aimagelab/svg_latent_space
- **Project page:** https://aimagelab.github.io/svg_latent_space/

## Model

SLS is a Transformer autoencoder that maps each SVG path to a 1024 dimensional
latent vector and decodes it back to symbolic geometry and style. The released
model has 8 encoder layers, 8 decoder layers, 8 attention heads, a vocabulary of
448 tokens, and 135,774,656 learned parameters.

This is a custom PyTorch model loaded using the code repository linked above.
The architecture is described in `config.json`, and `configs/sls.yaml` contains
the training and inference settings used by the code.

## Files

```text
weights/sls/model.safetensors
tokenizer/tokenizer.model
tokenizer/tokenizer.vocab
configs/sls.yaml
config.json
assets_manifest.json
LICENSE
```

The release contains the pretrained model and tokenizer. Optimizer, scheduler,
RNG states, training logs and datasets are not included. SHA256 checksums for
the model and tokenizer are recorded in `assets_manifest.json`.

## Quick start

Clone the code repository and install its dependencies using Python 3.11:

```bash
git clone https://github.com/aimagelab/svg_latent_space.git
cd svg_latent_space
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

Download the assets and set the required environment variable:

```bash
hf download lzini/SLS --local-dir sls_release
export SLS_ASSETS_DIR="$(realpath sls_release)"
```

**In this version, `SLS_ASSETS_DIR` must be exported before using the default
config for training or inference.** Repeat the export in each new terminal.

```bash
python inference.py reconstruct --input examples/example.svg --output outputs/reconstructed.svg
python inference.py encode --input examples/example.svg --output outputs/embeddings.safetensors
python inference.py decode --input outputs/embeddings.safetensors --output outputs/decoded.svg
```

CUDA is used when available. Add `--device cpu` to select CPU execution.
See the code repository for training, fine-tuning and checkpoint-resume commands.

## Representation and limits

The model uses last-token pooling (`cls_mode: last`) and produces raw latent
vectors (`l2norm: false`). Preserve their magnitude when decoding. Normalize a
separate copy when computing cosine similarity.

The inference code canonicalizes supported SVG shapes into paths on a 512×512
canvas, with rounded coordinates and serialized style. Inputs exceeding 1024
tokens per path are rejected. Arbitrary CSS and nested transforms are not fully
supported, and predicted SVG/XML paths may require validation.

## License

The released weights and tokenizer are licensed under Apache-2.0. See `LICENSE`.

## Citation

```bibtex
@inproceedings{zini2026scalable,
  title     = {A Scalable Vector Graphics Latent Space},
  author    = {Zini, Leonardo and Frigieri, Elia and Baraldi, Lorenzo},
  booktitle = {Proceedings of the European Conference on Computer Vision (ECCV)},
  year      = {2026}
}
```