fontgpt v1.5

A quick public release, not a polished one. v1.5 is a pretrain of the native outline tokenizer (outline2): a decoder-only transformer that draws font glyphs, each conditioned on its character, up to 16 glyphs of one font per sequence. Same family as fontgpt v1, with a new tokenizer, a bigger data mix and a longer run.

  • File: fontgpt_v1.5.pt, raw weights at step 12,050 (not the EMA), no optimizer state. Same format as fontgpt_v1.pt: model, model_config, data_config, merges, sources, step.
  • Model: 16 layers, width 768, 12 heads, SwiGLU MLP, U-Net skips, attention gates; 179.7M parameters, vocab 1,085, block size 2,560.
  • Tokenizer: outline2, --tokenizer outline2 --o2_q 128 --o2_nphi 23 --o2_nkap 8 --o2_tmode 1 --o2_fuse --o2_fine 8.
  • Schedule: 12,050 steps with a 2,250-step linear cooldown, about 1.7B real tokens.
  • Code: commit 747144b of the FontGPT code (pengpt.py, branch agent/outline2).

Held-out result

Unseen fonts, nats per glyph (lower is better):

all-64 clean-57
v1 135.42 130.39
v1.5 127.23 120.91

Run it

Install (Python 3.10+; tested with Python 3.12, torch 2.15 CPU build, numpy 2.5, numba 0.68, fontTools 4.69, skia-pathops 0.9):

pip install -r requirements.txt        # torch numpy numba fonttools skia-pathops pillow huggingface_hub
huggingface-cli download myssss/fontgpt-v1.5 --local-dir fontgpt-v1.5      # or: hf download myssss/fontgpt-v1.5 --local-dir fontgpt-v1.5
cd fontgpt-v1.5

Draw glyphs in the style of a font you give it (any TTF/OTF, ideally one the model has not seen):

python generate.py --font some.ttf --refs "HOno" --glyphs "abcdefg" --out out/ --compare --ttf
  • Input: --font (TTF/OTF), --refs (the characters of that font the model is shown first, default Hoag; they must exist in the font and have outlines), --glyphs (the characters to draw).
  • Output in --out: specimen.png (the references, the drawn glyphs, and with --compare the font's own glyphs for the same characters), one U+XXXX.svg per drawn glyph (true Bezier outlines, y down, baseline at y = 0), and with --ttf a generated.ttf holding the drawn glyphs.
  • Decoding: greedy by default, so the same inputs give the same glyphs. --temperature 0.8 samples instead; --seed makes it repeatable. --device cpu|cuda|auto, --max_tokens (budget per glyph, default 900) and --batch (glyphs decoded together) are the other options.
  • Speed: about 15 to 25 seconds per glyph on 6 CPU cores, plus model load; much faster on a GPU. Glyphs are decoded together, so a larger --glyphs is cheaper per glyph.
  • Files: generate.py (the CLI); code/ holds the model, tokenizer and decoder, copied from commit 747144b of the FontGPT code (code/COMMIT). code/decode.py is the batched decoder with the outline grammar mask and token budget that the release was evaluated with. If fontgpt_v1.5.pt is not beside generate.py, it is downloaded from this repo.

Known limits

  • Latin printable ASCII only (characters ! to ~); no accents or other scripts.
  • Quality depends on the references: more varied refs (a capital, a round letter, a lowercase with a stem, a descender) give a better style read. Odd or very decorative references give weaker results.
  • Long or complex glyphs (many contours, swashes, dense ornament) are weaker; a glyph can stop at the token budget or break the outline grammar, and the CLI says so per glyph.
  • Variable fonts are read at their default instance. The references must fit in the 2,560-token block (a few simple glyphs, fewer for complex ones).
  • Glyphs are drawn one by one: no kerning, hinting or spacing beyond the advance width the model writes.
  • This is a quick pretrain release: outlines can have small defects, and the model is not a finished font tool.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support