Wild1024 out-of-distribution: language 82.42, font-category 89.55.
1from huggingface_hub import snapshot_download
2import sys, torch, json
3from transformers import AutoProcessor
4from PIL import Image
5
6path = snapshot_download("issai/FontID")
7sys.path.insert(0, path)
8from modeling_fontid import FontIDModel
9
10model = FontIDModel.from_pretrained(path).eval()
11proc = AutoProcessor.from_pretrained("google/siglip2-base-patch16-naflex")
12maps = json.load(open(f"{path}/class_mappings.json"))
13
14img = Image.open("crop.png").convert("RGB")
15o = proc(images=img, max_num_patches=256, return_tensors="pt")
16with torch.no_grad():
17 out = model(o["pixel_values"], o["pixel_attention_mask"], o["spatial_shapes"])
18for head in ["font", "lang", "color", "style"]:
19 idx = int(out[head].argmax(-1))
20 print(head, maps[head][str(idx)])
Paper is coming soon.