textureSVG

One forward pass tells an SVG texture solver where to start.

textureSVG is a 38.4 M-parameter vision model. You give it a square texture image, it returns three things: which of 43 closed-set SVG filter graphs the material belongs to, where inside that graph's canonical parameter window the material sits (7 coordinates, all normalised to 0-1), and the two colours of the material.

It does not emit SVG. The coordinates are a starting point for a solver that renders the graph in a pinned reference browser and refines it until the rendered result is measurably faithful. Every fidelity number in this card is a measurement made on the rendered raster, never on the network output. That is the design rule of the project: the network proposes, the measurement decides.

What is in this repository, and what is deliberately not

Included Not included
model.safetensors β€” fp32 weights, 156 tensors, architecture in the file header the filter DSL (the 43 graphs themselves)
inference.py β€” standalone, no project imports the compiler that turns parameters into canonical SVG
requirements.txt, figures, this card the solver, its budget ladder and its acceptance test

That split is intentional: the u coordinates are positions inside a private canonical window, so they are meaningful coordinates only next to the graph they refer to. They are not a public parameter format.

Quick start

pip install -r requirements.txt
python inference.py --model model.safetensors --image assets/example_input.png

Real output, verbatim (fp32, CPU):

{
  "top": [["C07", 0.9908], ["A06", 0.0011], ["F03", 0.0011]],
  "template": "C07",
  "confidence": 0.9908,
  "u": [0.81, 0.8189, 0.2282, 0.6655, 0.419, 0.1948, 0.8559],
  "colors": {"base_color": "#6a5b76", "light_color": "#43b8b5"},
  "colors_raw": [0.415, 0.3561, 0.463, 0.2621, 0.7208, 0.7111],
  "image": "example_input.png",
  "model": {"weights": "model.safetensors", "parameters": 38384184,
            "templates": 43, "slots": 7, "quantized": "fp32", "device": "cpu",
            "inference_ms": 67.0}
}

inference_ms here is one cold forward pass in a fresh Python process; the steady-state cost measured over 500 textures in one process is 36 ms fp32 / 22 ms int8 (see Quantization). template is the graph id, u is the position inside that graph's canonical window, colors is the two-colour prediction. --int8 applies dynamic qint8 quantization to the linear layers: 1.6x faster on CPU at the cost of a different, non-interchangeable verdict set.

Input contract (part of the fidelity contract)

  • image -> RGB -> resize to 256x256 with Lanczos -> /127.5 - 1.0 -> fp32, no_grad
  • weights form must be declared with any fidelity claim: fp32 or qint8 dynamic (CPU only). They are not interchangeable.
  • all fidelities below were measured against Chromium 159.0.8154.6 via Playwright 1.65.2, pinned, with color-interpolation-filters="sRGB" on every filter. The same parameter vector on another engine is a different image.

The vocabulary: 43 graphs in 8 families

The DSL is a closed set, not an open language: a material outside these 43 graphs is declared not reproducible rather than approximated with an invented graph.

graphs
A stone A01 granite, A02 basalt, A03 pumice/scoria, A04 sandstone, A05 slate, A06 marble, A07 gneiss
B metal B01 brushed stainless, B02 satin aluminium, B03 cast/wrought iron, B04 patinated copper/brass, B05 rust colour-field, B06 rust grain+relief
C wood C01 striped wood, C02 growth rings, C03 longitudinal pores, C04 bark, C05 cork, C06 bamboo, C07 knots
D textile/paper D01 kraft/cotton, D02 corrugated board, D03 wicker/braid, D04 linen, D05 denim/twill, D06 velvet/suede, D07 silk/satin
E ground E01 desert sand, E02 clay/humus, E03 cracked dry mud, E04 gravel, E05 compact snow
F ceramic/glass F01 terracotta/brick, F02 glazed majolica, F03 frosted glass, F04 wavy glass, F05 matte plastic
G liquid/wax G01 water ripples, G02 light wave, G03 wax, G04 cellular surface
H sponge/foam H01 natural sponge/closed-cell foam, H02 aerated dough/bread/aerogel

u[i] is the i-th free parameter of the chosen graph, ordered by parameter name, mapped to its canonical window. The mapping is non-linear (for example baseFrequency is stored as a log), so u = 0.742 is not "74% of the range" β€” it is a position in that graph's window. u slots beyond a graph's parameter count are predicted but unused. The model predicts no seed and no enum values: seeds stay a solver search (see below), which is why slot = 7 is a padded width and not a promise.

How the model was built β€” generically, from measurements

No architecture, dataset or threshold was guessed. Everything below was measured first.

  1. A closed, canonically serialised DSL. 43 graphs, deterministic serialisation, a canonical parameter window per graph, tiled <pattern> first-class alongside filters. Round-trip JSON -> SVG -> decompile is verified on every graph, and the compiler refuses to emit a graph whose node would be a visual identity.
  2. The corpus is rendered from that DSL, and from nothing else. 30,000 images (seed 20261128), 697-698 per template, deduplicated by raster hash (0 duplicates) after a structure screen rejected 137 draws during generation. Zero real photographs, zero external images. This is why the model is out of distribution on photographs, and the card says so below rather than hiding it.
  3. The metric was frozen before any fit. Hand-written MS-SSIM, radial FFT band profile (13 geometric bands + DC), total-variation on 32-bin per-channel histograms plus 64-bin luminance Wasserstein-1, and an RMS deviation in standard-deviation units. Thresholds set at the p05 of the 903 distinct-template pairs at 512^2 β€” a fit must be closer than the nearest different template: MS-SSIM >= 0.90, d_bande <= 0.1011, d_ist <= 0.5437, deviation <= 10%. Re-measured at 128^2 and 256^2 the same rule drifts 2-3%, so one rule holds across the resolution ladder. Calibration: 0 of 903 different-template pairs pass; 3 of 86 deliberate perturbations pass, and those 3 are exactly the parameter directions already known to be unidentifiable.
  4. The seed is not learned β€” measured, not assumed. Holding every parameter at its canonical value and changing only the noise seed pushes the full composite to d = 0.355 median at 512^2 (MS-SSIM 0.226), because MS-SSIM and the RMS term demand the exact seed. Enumerating the 65,536 seeds of the window costs ~315 s at 128^2 and the product budget is 2-5 s, so the search objective is the phase-tolerant distance d_stat = (0.30*d_bande + 0.25*d_ist) / 0.55, and the acceptance is declared in two forms: statistical fidelity always, full pixel fidelity only when the seed was actually enumerated. Same perturbation under d_stat: 0.0130, i.e. inside thresholds β€” same texture, different noise phase.
  5. Architecture written from scratch, random initialisation. Pre-LN ViT: patch 16 on the 256^2 view -> 256 tokens + cls, d = 512, 12 layers, 8 heads, MLP 2048. Three heads: 43-way graph head, masked L1 regression on the 7 normalised coordinates (masked, because most graphs use fewer than 7), L1 on 6 colour channels. 38,384,184 parameters, one safetensors file, no pickle.
  6. Training. AdamW, warmup + cosine, bf16, 36 epochs / 16,884 steps on a single RTX 5070 Ti. Nothing external: no pretrained weights, no third-party tokenizer or vocabulary, no LLM-generated labels, no distillation from a third-party teacher. The header inside the weights file records view size, patch, d, layers, heads, the 43 ids, the epoch, the seed and the partitions, so this claim is checkable from the file.

Measured results

Evaluated on 500 held-out textures from the project's own generator (seed 20261126, never in training; the classifier's reference catalogue is a further separate set of 215 images, so a per-sample split of the evaluation set would have been leakage).

Graph classification (zero render cost, 16 s for 500 textures on CPU):

textureSVG k-NN on metric embeddings (previous stage)
top-1 69.6% (348/500) 21.8%
top-3 88.0% 42.0%
top-5 94.4% 55.6%

Six graphs the k-NN never got right at rank 1 are now largely right: A01 7/11, C04 7/11, D06 7/11, D07 4/12, F04 11/12, F05 5/11. Weakest family: E (ground) 26/60 β€” low-relief materials.

Two honesty notes about these numbers:

  • the weights header carries top1_val = 0.9108, and that number is contaminated: the delivered model is trained on both train and val partitions (they were split by family, see the next bullet). The honest number is the 69.6% holdout figure above.
  • a diagnostic run that held out families A and F entirely gave top-1 0.0 on them. The graph head does not generalise to unseen families. That is why the delivered model covers all 43 graphs, and why a material outside the 43 is refused, not recognised.

Inside the solver (same 500 textures, product budget 150 evaluations at 128^2 + 80 at 256^2 + 4 checks at 512^2, ~216 renders median):

configuration above statistical thresholds median time
cold start, one descent 266/500 2.46 s
cold start, 3-candidate cascade 347/500 (199 cases over 5 s) 2.95 s
one descent started from the network 377/500 (75.4%), 0 cases over 5 s 2.42 s
network answer rendered once, no descent 123/500 (24.6%) 1 render

The network's starting point wins at every rung of the budget ladder (12/8: 198 vs 136, 24/12: 243 vs 161, 48/24: 286 vs 230, 150/80: 377 vs 300) and on 336/500 textures individual d_stat improves.

The original plan asked for a 10x reduction in renders. It was not reached, and the measured factor is 3-4x: 2.99x at a fixed render cap, 3.94x with a hybrid policy ("render the network's answer, descend only if it fails"). The real value found is of a different sign: one network-initialised descent replaces the candidate cascade β€” more textures accepted, in less time, with nobody over the 5 s budget.

Quantization (dynamic qint8 on linear layers, CPU):

  • top-1 graph identical to fp32 on 493/500; median |delta u| = 0.0083 (max 0.0539)
  • 7 of 500 textures change which graph is searched -> not neutral
  • end-to-end on 120 textures: verdicts change on 3-6 of 120, median d_stat marginally better under int8
  • 22 ms vs 36 ms per texture on CPU

Declare the weight form with any fidelity claim. A number produced with int8 weights is not interchangeable with the fp32 one, exactly like a number produced with a different browser version.

Example

Inside the perimeter: one render, accepted

assets/example_in_perimeter.png β€” input on the left, output on the right.

inside the perimeter

The input is a texture from the project's held-out set, rendered by this project's own DSL (not a photograph). The model returns C07 (wood: knots) at 99.08% confidence, the solver accepts the network's parameter vector and renders it once, no descent:

d_stat d_bande d_ist verdict
0.0914 0.0676 0.1199 passes the statistical contract (limits 0.1011 / 0.5437)

The full pixel-aligned composite on the same pair is MS-SSIM 0.185 and deviation 105%, which is the expected result for a seeded graph whose seed was not enumerated β€” the material and its scale and its grain match, the noise phase does not. The colours are the network's own prediction (#6a5b76, #43b8b5), which is why the two panels read slightly different in hue: colour is a coarse head, structure is the strong one.

A public-domain photograph: published, measured, and it does not pass

assets/example_out_of_perimeter.png β€” input on the left, output on the right.

out of perimeter

Input licence. Photograph "Sunlit Crushed Stones" by Paul The Writer, released under CC0 on Wikimedia Commons: https://commons.wikimedia.org/wiki/File:Sunlit_Crushed_Stones.jpg β€” deed: http://creativecommons.org/publicdomain/zero/1.0/deed.en. It is used as downloaded (1024x1360); the network view is the contract's 256^2 Lanczos resize with no crop, so the image is squashed into the square β€” a centre-crop variant was measured too and is no better (best 0.1962). The panels above are displayed from a central square crop.

The model reads it as C04 (bark) with 95.3% confidence β€” a plausible family, and the output is genuinely granular and stony β€” but after a full descent at the product budget (218 renders, 3.9 s) the measurement says d_stat 0.2344, with d_bande 0.2174 far over the 0.1011 limit: rejected.

This is not one bad luck. Probing 43 distinct licensed images from Wikimedia Commons (CC0, public domain, CC BY, CC BY-SA) with 70 descents at the product budget: zero pass, the best d_stat of the whole probe is 0.1893 (a CC0 seamless slate texture, and it fails on d_bande 0.132 alone), and on grainy stone/soil photographs the graph head collapses onto C04 (bark) for 22 of the 43 images.

Photographs are declared out of perimeter in this project's design document, and that declaration is measurement-backed rather than aspirational.

Limits, read them before using the model

  1. The model's input distribution is renders of the DSL. Real photographs are out of perimeter and out of distribution: measured above.
  2. The graph head does not transfer to unseen families (diagnostic top-1 0.0 on families A and F).
  3. Colour is coarse. Even with an oracle for structure, the per-coordinate colour MAE floor measured without any network is 0.07-0.13 on the 0-1 scale.
  4. No seed prediction, and none planned. A seed-only change costs d = 0.355 in the pixel-aligned composite; recovering it costs ~315 s of rendering, which does not fit a 2-5 s product budget. Statistical fidelity is the contract; pixel fidelity is a bonus that requires the seed to have actually been enumerated.
  5. A fidelity number is meaningless without the renderer version and the weight form. Chromium 159.0.8154.6 / Playwright 1.65.2, fp32 or qint8 declared.
  6. u is not a public parameter format. It is an address inside a private canonical window; the graphs, the compiler and the solver are not part of this repository.

Files

model.safetensors        146.4 MB, 156 tensors, 38,384,184 parameters, fp32
                         (conventional HF single-file checkpoint name; the model's name
                          is the repository: tailot/textureSVG)
inference.py             standalone CLI: image in, JSON out (see Quick start)
requirements.txt         pinned versions the numbers above were measured with
LICENSE.md               all rights reserved + third-party licences of the figures
assets/                  the two example figures and their inputs

Licence

All rights reserved β€” see LICENSE.md. No licence is granted for the weights or for inference.py; contact the repository owner for permission. Third-party material in the figures keeps its own terms (the CC0 photograph credited above).

Downloads last month

-

Downloads are not tracked for this model. How to track
Safetensors
Model size
38.4M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support