Instructions to use HERIUN/mxfontpp-korean-handwriting with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HERIUN/mxfontpp-korean-handwriting with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-to-image", model="HERIUN/mxfontpp-korean-handwriting", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("HERIUN/mxfontpp-korean-handwriting", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
MX-Font++ β Korean Handwriting (B@340K)
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
Files
model.safetensors+config.json+modeling_mxfontpp.pyβ inference weights (generator_ema) and the self-contained model code, fortransformers. 30.8M params.mxfontpp_korean_hand_340k.pthβ full training checkpoint (generator,generator_ema,discriminator, optimizer states), for resuming training in the original repo.
Usage
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:
- There is no image processor and no
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_refis variable; more references average toward a more stable style.
Training
- Trained from scratch on a Korean font set (print + Nanum handwriting) β not finetuned from any base checkpoint.
- Data: free Korean fonts (Google Fonts + Naver Nanum handwriting), not
redistributed. List in the repo's
FONTS.md. - Steps: 340000. Korean decomposition/primals JSON are in the code repo.
Intended use & limitations
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.
License & credit
- Downloads last month
- 88