DeepVecFont
This is the official Pytorch implementation of the paper:
Yizhi Wang and Zhouhui Lian. DeepVecFont: Synthesizing High-quality Vector Fonts via Dual-modality Learning. SIGGRAPH 2021 Asia. 2021.
Paper: arxiv
Demo
Few-shot generation
Given a few vector glyphs of a font as reference, our model generates the full vector font:
Input glyphs:
Synthesized glyphs by DeepVecFont:Input glyphs:
Synthesized glyphs by DeepVecFont:Input glyphs:
Synthesized glyphs by DeepVecFont:Installation
Requirement
- python 3.9
- Pytorch 1.9 (it may work on some lower versions, but not tested)
Please use Anaconda to build the environment:
conda create -n dvf python=3.9
source activate dvf
Install pytorch via the instructions.
Install diffvg
We utilize diffvg to refine our generated vector glyphs in the testing phase. Please go to https://github.com/BachiLi/diffvg see how to install it.
Data and Pretrained-model
Dataset
- The Vector Font dataset Download links: Google Drive
Please download the vecfont_dataset
dir and put it under ./data/
. (This dataset is a subset from SVG-VAE, ICCV 2019. We will release more information about how to create from your own data.)
- The mean and stdev files Download links: Google Drive
Please Download them and put it under ./data/
.
Pretrained model
- The Neural Rasterizer Download links: Google Drive
Please download the dvf_neural_raster
dir and put it under ./experiments/
.
- The Image Super-resolution model Download links: Google Drive.
Please download the image_sr
dir and put it under ./experiments/
. Note that recently we switched from Tensorflow to Pytorch, we may update the models that have better performances.
- The Main model Download links: [will be uploaded soon].
Training and Testing
To train our main model, run
python main.py --mode train --experiment_name dvf --model_name main_model
The configurations can be found in options.py
.
To test our main model, run
python test_sf.py --mode test --experiment_name dvf --model_name main_model --test_epoch 1500 --batch_size 1 --mix_temperature 0.0001 --gauss_temperature 0.01
This will output the synthesized fonts without refinements. Note that batch_size
must be set to 1.
To refinement the vector glyphs, run
python refinement.mp.py --experiment_name dvf --fontid 14 --candidate_nums 20
where the fontid
denotes the index of testing font.
We have pretrained the neural rasterizer and image super-resolution model. If you want to train them yourself:
To train the neural rasterizer:
python train_nr.py --mode train --experiment_name dvf --model_name neural_raster
To train the image super-resolution model:
python train_sr.py --mode train --name image_sr