hangul-font-finder

GitHub

Identifies the free Korean font used in an image of a single line of Hangul text.

ํ•œ๊ธ€ ํ…์ŠคํŠธ ํ•œ ์ค„ ์ด๋ฏธ์ง€์—์„œ ์‚ฌ์šฉ๋œ ๋ฌด๋ฃŒ ํ•œ๊ธ€ ํฐํŠธ๋ฅผ ์‹๋ณ„ํ•˜๋Š” ๋ชจ๋ธ์ž…๋‹ˆ๋‹ค.

  • Identifies 1,279 free Korean fonts (1,393 font families, Fonts List)
  • Robust to outlines, shadows, 3D extrusion, gradients, horizontal scaling, partial occlusion, low resolution and compression
  • One line image in, no OCR or character segmentation
  • Outputs calibrated font probabilities
  • Trained on synthetic data
Input Top-1 Prob.
Black Han Sans 0.996
Jua 0.996
Do Hyeon 0.994

Usage

pip install torch transformers safetensors pillow numpy huggingface_hub
import sys
from huggingface_hub import snapshot_download
from PIL import Image

path = snapshot_download("prenny/hangul-font-finder")
sys.path.insert(0, path)
from inference import FontIdentifier

model = FontIdentifier(path)
model.predict(Image.open("line.png"), top=5)
# [{'font': 'Jua', 'same_shape_fonts': ['BM JUA_TTF', 'Jua'],
#   'korean_name': '๋ฐฐ๋‹ฌ์˜๋ฏผ์กฑ ์ฃผ์•„', 'probability': 0.9955}, ...]
  • Input is an image of one cropped text line. Text detection is not included.
  • Fonts with identical Hangul glyphs (OTF/TTF builds, English/Korean names, Google Fonts releases) are returned as one font, with all names in same_shape_fonts.
  • Runs on CUDA, MPS and CPU.

Evaluation

Test set Lines Top-1 Top-3 Top-5
Hard (mixed effects) 2,702 93.3% 97.9% 98.7%
Clean 1,351 97.4% โ‰ฅ 99.2% โ‰ฅ 99.8%

Predictions with probability โ‰ฅ 0.95 cover 84% of the hard set at 99.6% accuracy.

Training

  • Architecture: SigLIP 2 Base vision encoder (fully fine-tuned) + 512-d projection + linear classifier
  • Input encoding: greyscale, resized to 56 px height (aspect preserved), folded into 4 rows of a 224ร—224 image; long lines averaged over 3 windows
  • Data: about 400k synthetic line images (about 300 per font)
  • Schedule: 6 epochs, AdamW (lr 3e-5), batch 128, label smoothing 0.1, temperature-calibrated (T = 0.690), 1ร— RTX 5080 (about 85 min)

Limitations

  • Fonts outside the 1,279 known fonts are answered with the most similar known font, usually with a low probability.
  • All reported numbers are measured on synthetic images.
  • Designed for Hangul; lines with only Latin letters or digits were not evaluated.
  • The model only provides font names. Check each font's licence before use.

License

MIT. Weights are fine-tuned from SigLIP 2 (Apache-2.0); see LICENSE-SIGLIP2-APACHE-2.0 and NOTICE.

Downloads last month
29
Safetensors
Model size
94M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for prenny/hangul-font-finder

Finetuned
(153)
this model