FontID β€” SigLIP2 NaFlex, four-head font analyzer

Predicts font family (75), language (11), color (64, EGA index), and style (4) from a text-image crop. Backbone: google/siglip2-base-patch16-naflex (native aspect ratio, max_num_patches=256); pooled feature (d=768) from the SigLIP2 attention-pooling head feeds four independent heads (Linear(768β†’512) β†’ LayerNorm β†’ GELU β†’ Dropout(0.1) β†’ Linear(512β†’n)).

Results (DataFontID test)

font language color style
96.34 96.19 95.92 96.98

Wild1024 out-of-distribution: language 82.42, font-category 89.55.

Usage

from huggingface_hub import snapshot_download
import sys, torch, json
from transformers import AutoProcessor
from PIL import Image

path = snapshot_download("issai/FontID")
sys.path.insert(0, path)
from modeling_fontid import FontIDModel

model = FontIDModel.from_pretrained(path).eval()
proc  = AutoProcessor.from_pretrained("google/siglip2-base-patch16-naflex")
maps  = json.load(open(f"{path}/class_mappings.json"))

img = Image.open("crop.png").convert("RGB")
o = proc(images=img, max_num_patches=256, return_tensors="pt")
with torch.no_grad():
    out = model(o["pixel_values"], o["pixel_attention_mask"], o["spatial_shapes"])
for head in ["font", "lang", "color", "style"]:
    idx = int(out[head].argmax(-1))
    print(head, maps[head][str(idx)])

Citation

Paper is coming soon.

Downloads last month
-
Safetensors
Model size
94.6M params
Tensor type
F32
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for issai/FontID

Finetuned
(2)
this model

Datasets used to train issai/FontID

Collection including issai/FontID