All Projects → clovaai → lffont

clovaai / lffont

Licence: other
Official PyTorch implementation of LF-Font (Few-shot Font Generation with Localized Style Representations and Factorization) AAAI 2021

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to lffont

fewshot-font-generation
The unified repository for few-shot font generation methods. This repository includes FUNIT (ICCV'19), DM-Font (ECCV'20), LF-Font (AAAI'21) and MX-Font (ICCV'21).
Stars: ✭ 76 (-30.91%)
Mutual labels:  font, generative-models, font-generation
PlemolJP
IBM Plex Mono と IBM Plex Sans JP を合成したプログラミングフォント PlemolJP (プレモル ジェイピー)
Stars: ✭ 683 (+520.91%)
Mutual labels:  font
ModernUI
Modern desktop framework from low-level 3D graphics API to high-level view model, for development of 2D/3D rendering software or game engine, with internationalization support and many new technologies.
Stars: ✭ 168 (+52.73%)
Mutual labels:  font
kuu-pyaung
Laravel package to convert files and database from zawgyi to unicode.
Stars: ✭ 13 (-88.18%)
Mutual labels:  font
EC-GAN
EC-GAN: Low-Sample Classification using Semi-Supervised Algorithms and GANs (AAAI 2021)
Stars: ✭ 29 (-73.64%)
Mutual labels:  aaai2021
simsg
Semantic Image Manipulation using Scene Graphs (CVPR 2020)
Stars: ✭ 49 (-55.45%)
Mutual labels:  generative-models
three-font-outliner
Constructing shapes from glyphs at runtime for three.js.
Stars: ✭ 58 (-47.27%)
Mutual labels:  font
RitaFontTester
Auxiliary tool for the development of Persian-Arabic fonts
Stars: ✭ 16 (-85.45%)
Mutual labels:  font
segoe-ui-linux
🐒 Install segoe-ui font on linux (ubuntu)
Stars: ✭ 121 (+10%)
Mutual labels:  font
Chilanka
Chilanka handwriting style Malayalam font
Stars: ✭ 18 (-83.64%)
Mutual labels:  font
MARIOFont
The Mario fonts you usually see in Mario games
Stars: ✭ 56 (-49.09%)
Mutual labels:  font
urdu-font-comparator-app
App for visually showing why Nasta'liq is better than Naskh script, how different Urdu fonts look like and eventually helping users in choosing the best one.
Stars: ✭ 20 (-81.82%)
Mutual labels:  font
MaterialDesign-Font
Distribution Repo for the TTF font
Stars: ✭ 102 (-7.27%)
Mutual labels:  font
SGRAF
The code of “Similarity Reasoning and Filtration for Image-Text Matching” [AAAI2021]
Stars: ✭ 136 (+23.64%)
Mutual labels:  aaai2021
dotfiles
Repository to manage and share personal dotfiles
Stars: ✭ 67 (-39.09%)
Mutual labels:  font
KGNPreferredFontManager
Helper class to registering custom fonts for UIFontTextStyle
Stars: ✭ 19 (-82.73%)
Mutual labels:  font
ufolint
UFO source format linter
Stars: ✭ 23 (-79.09%)
Mutual labels:  font
MultiFontViewKotlin-Android
MultiFontViewKotlin library can be used to select custom fonts for the view dynamically in your XML
Stars: ✭ 13 (-88.18%)
Mutual labels:  font
xfl
load large fonts by splitting font file according to word frequency.
Stars: ✭ 14 (-87.27%)
Mutual labels:  font
AttaNet
AttaNet for real-time semantic segmentation.
Stars: ✭ 37 (-66.36%)
Mutual labels:  aaai2021

Few-shot Font Generation with Localized Style Representations and Factorization (AAAI 2021)

NOTICE: We release the unified few-shot font generation repository (clovaai/fewshot-font-generation). If you are interested in using our implementation, please visit the unified repository.

Official PyTorch implementation of LF-Font | paper | paper (PAMI extension)

Song Park1*, Sanghyuk Chun2*, Junbum Cha2, Bado Lee2, Hyunjung Shim1
* Equal contribution

1 School of Integrated Technology, Yonsei University
2 Clova AI Research, NAVER Corp.

Automatic few-shot font generation is in high demand because manual designs are expensive and sensitive to the expertise of designers. Existing methods of few-shot font generation aims to learn to disentangle the style and content element from a few reference glyphs and mainly focus on a universal style representation for each font style. However, such approach limits the model in representing diverse local styles, and thus make it unsuitable to the most complicated letter system, e.g., Chinese, whose characters consist of a varying number of components (often called "radical") with a highly complex structure. In this paper, we propose a novel font generation method by learning localized styles, namely component-wise style representations, instead of universal styles. The proposed style representations enable us to synthesize complex local details in text designs. However, learning component-wise styles solely from reference glyphs is infeasible in the few-shot font generation scenario, when a target script has a large number of components, e.g., over 200 for Chinese. To reduce the number of reference glyphs, we simplify component-wise styles by a product of component factor and style factor, inspired by low-rank matrix factorization. Thanks to the combination of strong representation and a compact factorization strategy, our method shows remarkably better few-shot font generation results (with only 8 reference glyph images) than other state-of-the-arts, without utilizing strong locality supervision, e.g., location of each component, skeleton, or strokes.

You can find more related projects on the few-shot font generation at the following links:

Introduction

Pytorch implementation of Few-shot Font Generation with Localized Style Representations and Factorization.


Prerequisites

conda install numpy tqdm lmdb ruamel.yaml jsonlib-python3 msgpack

Usage

Prepare datasets

Build meta file to dump lmdb environment

  • To build a dataset with your own truetype font files (.ttf), a json-format meta file is needed:
    • structure: dict
    • format: {fontname: {"path": path/to/.ttf", "charlist": [chars to dump.]}}
    • example: {"font1": {"path": "./fonts/font1.ttf", "charlist": ["春", "夏", "秋", "冬"]}}

The font file we used as the content font can be accessed here.

Run script

python build_dataset.py \
    --lmdb_path path/to/dump/lmdb \
    --meta_path path/to/meta/file \
    --json_path path/to/save/dict
  • arguments
    • --lmdb_path: path to save lmdb environment.
    • --meta_path: path to meta file of built meta file.
    • --json_path: path to save json file, which contains information of available fonts and characters.
      • saved json file has format like this: {fontname: [saved character list in unicode format]}

Build meta file to train and test

  • train meta (dict, json format)

    • should have keys; "train", "valid", "avail"
    • "train": {font: list of characters} pairs for training, dict
      • key: font name / value: list of chars in the key font.
      • example: {"font1": ["4E00", "4E01"...], "font2": ["4E00", "4E01"...]}
    • "avail": {font: list of characters} pairs which are accessible in lmdb, dict
      • same format with "train"
    • "valid": list of font and list characters for validation, dict
      • should have keys: "seen_fonts", "unseen_fonts", "seen_unis", "unseen_unis"
      • seen fonts(unis) : list of fonts(chars in unicode) in training set.
      • unseen fonts(unis): list of fonts(chars in unicode) not in training set, for validation.
    • An example of train meta file is in meta/train.json.
  • test meta (dict, json format)

    • should have keys; "gen_fonts", "gen_unis", "ref_unis"
    • "gen_fonts": list of fonts to generate.
    • "gen_unis": list of chars to generate, in unicode
    • "ref_unis": list of chars to use as reference chars, in unicode
    • An example of test meta file is in meta/test.json.

Modify the configuration file

We recommend to modify cfgs/custom.yaml rather than cfgs/default.yaml, cfgs/combined.yaml, or cfgs/factorize.yaml.

keys

  • use_half
    • whether to use half tensor. (apex is needed)
  • use_ddp
    • whether to use DataDistributedParallel, for multi-gpus.
  • work_dir
    • the root directory for saved results.
  • data_path
    • path to data lmdb environment.
  • data_meta
    • path to train meta file.
  • content_font
    • the name of font you want to use as source font.
  • other values are hyperparameters for training.

Train

# Phase 1 training
python train.py \
    NAME_phase1 \
    cfgs/custom.yaml cfgs/combined.yaml 

# Phase 2 training
python train.py \
    NAME_phase2 \
    cfgs/custom.yaml cfgs/factorize.yaml \
    --resume ./result/checkpoints/NAME_phase1/800000-NAME_phase1.pth
  • arguments
    • NAME (first argument): name for the experiment.
      • the (checkpoints, validation images, logs) are saved in ./results/(checkpoints, images, logs)/NAME
    • path/to/config (second argument): path to configration file.
      • multiple values are allowed, but their keys should not be repeated.
      • cfgs/combined.yaml : for phase 1 training.
      • cfgs/factorize.yaml: for phase 2 training.
    • --resume (optional) : path to checkpoint to resume.

Test

python evaluator.py \
    cfgs/factorize.yaml \
    --weight weight/generator.pth \
    --img_dir path/to/save/images \
    --test_meta meta/test.json \
    --data_path path/to/data
  • arguments
    • path/to/config (first argument): path to configration file.
    • --weight : path to saved weight to test.
    • --img_dir: path to save generated images.
    • --test_meta: path to test meta file.
    • --data_path: path to lmdb dataset which contatins the reference images.

Code license

This project is distributed under MIT license, except modules.py which is adopted from https://github.com/NVlabs/FUNIT.

LF-Font
Copyright (c) 2020-present NAVER Corp.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Acknowledgement

This project is based on clovaai/dmfont.

How to cite

@inproceedings{park2021lffont,
    title={Few-shot Font Generation with Localized Style Representations and Factorization},
    author={Park, Song and Chun, Sanghyuk and Cha, Junbum and Lee, Bado and Shim, Hyunjung},
    year={2021},
    booktitle={AAAI Conference on Artificial Intelligence},
}

@article{park2022lffont_extension,
    author={Park, Song and Chun, Sanghyuk and Cha, Junbum and Lee, Bado and Shim, Hyunjung},
    journal = {IEEE Transactions on Pattern Analysis & Machine Intelligence},
    title = {Few-shot Font Generation with Weakly Supervised Localized Representations},
    year = {5555},
    volume = {},
    number = {01},
    issn = {1939-3539},
    pages = {1-17},
    keywords = {},
    doi = {10.1109/TPAMI.2022.3196675},
    publisher = {IEEE Computer Society},
    address = {Los Alamitos, CA, USA},
    month = {aug}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].