This repo is the official implementation of paper, SGD-Font: Style and Glyph Decoupling for One-Shot Font Generation.
pytorch>=1.13.0
opencv-python
sklearn
pillow
tqdm
blobfile>=1.0.5
mpi4py
attrdict
yaml
lpips
pytorch-fid
fonttools
We obtain fonts from the following font platforms under a personal non-commercial academic research license:
- Foundertype (https://www.foundertype.com);
- Font Meme (https://fontmeme.com/ziti/).
Example directory hierarchy
data_dir
Seen_TRAIN
|--- font1
|--- font2
|--- 0000.png
|--- 0001.png
|--- ...
|--- ...
Seen_TEST
Unseen_TRAIN
Unseen_TEST
Source_TRAIN
Source_TEST
python font2img.py --ttf_path ttf_folder --chara char.txt --save_path save_folder --img_size 80 --chara_size 50
Modify the configuration file cfg/train_cfg.yaml, and then run
-
single gpu
python train.py --cfg_path cfg/train_cfg.yaml
-
distributed training
mpiexec -n $NUM_GPUS python train.py --cfg_path cfg/train_cfg.yaml
Modify the configuration file cfg/test_cfg.yaml, and then run
bash sample.sh
Modify the path to your result, and run
bash evaluate.sh
(1)Seen Font Unseen Content
(2)Unseen Font Unseen Content
This project is based on openai/guided-diffusion and CF-Font