Downloads · 30 days
60
50% of all-time downloads
HERIUN/mxfontpp-korean-handwriting
mxfontpp-korean-handwriting is a image-to-image model from HERIUN. Use it when you need one image transformed into another. It is set up for transformers. The card lists the license as mit.
MX-Font++ trained on a Korean font set (print + Nanum handwriting) to generate Korean glyphs in a given handwriting style. This is the main handwriting model from the project ("B@340K"), i.e. training step 340000.
Downloads · 30 days
60
50% of all-time downloads
All-time downloads
119
Public
Parameters
30.8M
903 MB on disk
Likes
0
Public
Click a slice to open those files.
.pth780 MB · 86%
From the Hugging Face model README
MX-Font++ trained on a Korean font set (print + Nanum handwriting) to generate Korean glyphs in a given handwriting style. This is the main handwriting model from the project ("B@340K"), i.e. training step 340000.
Custom architecture, so transformers runs it as remote code
(trust_remote_code=True) — the modeling file ships in this repo. The original
training repo is 👉 https://github.com/HERIUN/MXFontpp-korean
model.safetensors + config.json + modeling_mxfontpp.py — inference
weights (generator_ema) and the self-contained model code, for
transformers. 30.8M params.mxfontpp_korean_hand_340k.pth — full training checkpoint
(generator, generator_ema, discriminator, optimizer states),
for resuming training in the original repo.pip install transformers torch torchvision einops
import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModel
model = AutoModel.from_pretrained(
"HERIUN/mxfontpp-korean-handwriting", trust_remote_code=True
).eval()
tf = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize([0.5], [0.5]),
])
# style_imgs: a few reference glyphs of the target style -> (B, n_ref, 1, 128, 128)
# char_imgs : the content glyph from a source font -> (B, 1, 1, 128, 128)
style = torch.stack([tf(Image.open(p).convert("L")) for p in ref_paths]).unsqueeze(0)
char = tf(Image.open(src_path).convert("L")).unsqueeze(0).unsqueeze(0)
with torch.no_grad():
out = model(style_imgs=style, char_imgs=char) # (B, 1, 128, 128), sigmoid: 0 = ink, 1 = paper
Image.fromarray((out[0, 0] * 255).byte().numpy()).save("gen.png")
Notes:
pipeline() support: the model takes
two inputs (N style references + 1 content glyph), which no single-image
task signature covers. Do the preprocessing above yourself.n_ref is variable; more references average toward a more stable style.FONTS.md.Meant to fill the long tail of a Korean font set (glyphs beyond the common
KS2350 set) in a consistent style. Per-writer / out-of-distribution style
transfer is not reliable — the style manifold collapses toward an average
hand. Finetuning attempts to fix this (style_consist / style_supcon losses
in the repo) hit a −0.02~−0.04 IoU ceiling and did not break the collapse. For
faithful per-writer transfer use DM-Font instead; use this model for the
in-distribution tail-fill it does well.