Home

Awesome

Typography-with-Decor

<img src="https://github.com/daooshee/Typography-with-Decor/blob/master/teasor.png" width="600" alt="Example"/>

Typography with Decor: Intelligent Text Style Transfer <br> Wenjing Wang, Jiaying Liu, Shuai Yang, and Zongming Guo <br> CVPR, 2019

[Project Page], [Paper]

Update 190707: fix a bug in README.md and add a python version for glyph pre-processing.

Setup

Prerequisites

Getting Started

git clone https://github.com/daooshee/Typography-with-Decor.git
cd Typography-with-Decor

Quick Testing

python runtest.py

Testing Custom Images

x = imread('input.png'); 

I = im2bw(x(:,:,1));
I2 = bwdist(I, 'euclidean');
I3 = bwdist(~I, 'euclidean');
x(:,:,3) = min(255, I2);
x(:,:,2) = min(255, I3);

imwrite(x,'result.png');

The following python function works too:

import cv2
import numpy as np
from scipy.ndimage.morphology import distance_transform_edt as bwdist

def PreProcess(img_path):
    img = cv2.imread(img_path)
    I = img[:,:,2]
    I2 = bwdist(I <= 100);
    I3 = bwdist(I > 100);

    img[:,:,0] = np.clip(I2,0,255);
    img[:,:,1] = np.clip(I3,0,255);

    return img

Training Basal Text Effect Transfer

Training Decor Segmentation

python train_domain_adaptation.py --gpu 0 --batchSize 90 --niter 17000 --use_decay
python train_domain_adaptation.py --gpu 0 --batchSize 15 --niter 170000 --use_decay --use_perceptual
python train_domain_adaptation.py --gpu 0 --batchSize 10 --niter 5000 --use_decay --use_perceptual --domain_adaptation

Citation

If you use this code for your research, please cite our paper:

@InProceedings{typography2019,
   author = {Wang, Wenjing and Liu, Jiaying and Yang, Shuai and Guo, Zongming},
   title = {Typography with Decor: Intelligent Text Style Transfer},
   booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
   month = {June},
   year = {2019}
}