Coder Social home page Coder Social logo

attr2font's Introduction

Attr2Font

Introduction

This is the official PyTorch implementation of the Attribute2Font: Creating Fonts You Want From Attributes.

Teaser

Paper: arXiv | Research Gate
Supplementary Material: link
Video: link
Code: GitHub

Abstract

Font design is now still considered as an exclusive privilege of professional designers, whose creativity is not possessed by existing software systems. Nevertheless, we also notice that most commercial font products are in fact manually designed by following specific requirements on some attributes of glyphs, such as italic, serif, cursive, width, angularity, etc. Inspired by this fact, we propose a novel model, Attribute2Font, to automatically create fonts by synthesizing visually pleasing glyph images according to user-specified attributes and their corresponding values. To the best of our knowledge, our model is the first one in the literature which is capable of generating glyph images in new font styles, instead of retrieving existing fonts, according to given values of specified font attributes. Specifically, Attribute2Font is trained to perform font style transfer between any two fonts conditioned on their attribute values. After training, our model can generate glyph images in accordance with an arbitrary set of font attribute values. Furthermore, a novel unit named Attribute Attention Module is designed to make those generated glyph images better embody the prominent font attributes. Considering that the annotations of font attribute values are extremely expensive to obtain, a semi-supervised learning scheme is also introduced to exploit a large number of unlabeled fonts. Experimental results demonstrate that our model achieves impressive performance on many tasks, such as creating glyph images in new font styles, editing existing fonts, interpolation among different fonts, etc.

Model Architecture

Architecture

Demonstration

Demo

Prerequisites

  • Linux
  • CPU or NVIDIA GPU + CUDA cuDNN
  • Python 3
  • PyTorch 1.0+

Get Started

Installation

  1. Install PyTorch, torchvison and dependencies from https://pytorch.org
  2. Clone this repo:
    git clone https://github.com/hologerry/Attr2Font
    cd Attr2Font
  3. Download the official pre-trained vgg19 model: vgg19-dcbb9e9d.pth, and put it under this project root folder

Datasets

Download the dataset from PKU Disk, Google Drive and put it into the data/:

data/
    explor_all/
        image/
        attributes.txt/

| This dataset is constructed by O’Donovan et al. Exploratory Font Selection Using Crowdsourced Attributes. TOG 2014

Model Training

python main.py --phase train

Model Testing

python main.py --phase test

Model Interpolation

python main.py --phase test_interp --test_epoch EPOCH

Citation:

If you use this code or find our work is helpful, please consider citing our work:

@article{WangSIGGRAPH2020,
  author = {Yizhi Wang*, Yue Gao*, Zhouhui Lian},
  title = {Attribute2Font: Creating Fonts You Want From Attributes},
  journal = {ACM Trans. Graph.},
  year = {2020}
}

| * Denotes equal contribution

Copyright

The code and dataset are only allowed for PERSONAL and ACADEMIC usage.

attr2font's People

Contributors

hologerry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

attr2font's Issues

about arguments of Test options

@hologerry

Could you explain each options meaning? (--channel, --attr_channel, --attr_embed, etc)
Actually, I want to know how to input attributes value to model.
If I want to make font which is similar with Serif font, how can I do ?

Thanks : )

在自建中文数据集上出现错误

感谢您出色的工作,我自己创建了一个中文数据集,运行时出现了以下错误
Traceback (most recent call last):
File "main.py", line 593, in
main()
File "main.py", line 581, in main
train(opts)
File "main.py", line 135, in train
attr_A_intensity = label_A * attr_A_data + (1 - label_A) * attr_A_embd
RuntimeError: The size of tensor a (17) must match the size of tensor b (37) at non-singleton dimension 1
出错的位置如图所示,图中两个print的输出分别为 torch.Size([64, 17]),torch.Size([64, 37])
图片

train error

2020-11-05 15-38-57屏幕截图
when input image size is 64 in style encoder,it will be transformed to a tensor which size is (1, 165, 1 ,1)
and it will be fed into residual black , which has a conv(kernel = 3) and generate an error.

What is the char class for?

It looks like the generator model includes a character classifier output, which classifies the character to one of 52 one-hot values. The number 52 is hardcoded: https://github.com/hologerry/Attr2Font/blob/master/model.py#L231. What is this for? The discriminator takes in a character class param, but then ignores it and never references it https://github.com/hologerry/Attr2Font/blob/master/model.py#L367. Is the char class being in this algorithm a mistake, or is it necessary for the font generation to function? If so, why?

RuntimeError: CUDA error: an illegal memory access was encountered

Hi, I can not run "Sampling " part code .

Attr2Font/main.py

Lines 242 to 248 in 810404b

val_attr_A_intensity = val_batch['attr_A'].to(device)
val_attr_A_intensity = attr_unsuper_tolearn(val_fontembed_A)
val_attr_A_intensity = val_attr_A_intensity.view(val_attr_A_intensity.size(0), val_attr_A_intensity.size(2))
val_attr_A_intensity = torch.sigmoid(3*val_attr_A_intensity) # convert to [0, 1]
val_attr_B_intensity = val_batch['attr_B'].to(device)

it occur in this part code .
And I confused L242 and L243 are the both set variable val_attr_A_intensity but with different value, why ?

Model Interpolation Error

I have done Model Training and Model Testing. When I start to do Model Interpolation, the error occurs as follows:

$ python main.py --phase test_interp --test_epoch EPOCH
usage: main.py [-h] [--init_epoch INIT_EPOCH] [--n_epochs N_EPOCHS]
               [--decay_epoch DECAY_EPOCH] [--multi_gpu MULTI_GPU]
               [--data_root DATA_ROOT] [--dataset_name {explor_all}]
               [--img_size IMG_SIZE] [--batch_size BATCH_SIZE]
               [--n_threads N_THREADS] [--n_style N_STYLE] [--channel CHANNEL]
               [--attr_channel ATTR_CHANNEL] [--attr_embed ATTR_EMBED]
               [--style_out_channel STYLE_OUT_CHANNEL]
               [--n_res_blocks N_RES_BLOCKS] [--attention ATTENTION]
               [--dis_pred DIS_PRED] [--lr LR] [--b1 B1] [--b2 B2]
               [--experiment_name EXPERIMENT_NAME] [--check_freq CHECK_FREQ]
               [--sample_freq SAMPLE_FREQ] [--log_freq LOG_FREQ]
               [--phase {train,test,test_interp}] [--test_epoch TEST_EPOCH]
               [--interp_cnt INTERP_CNT] [--lambda_l1 LAMBDA_L1]
               [--lambda_char LAMBDA_CHAR] [--lambda_GAN LAMBDA_GAN]
               [--lambda_cx LAMBDA_CX] [--lambda_attr LAMBDA_ATTR]
main.py: error: argument --test_epoch: invalid int value: 'EPOCH'

Random result glyphs from generator

Hi!
Found that the generator always produces random glyphs with the same attribute parameters passed (intensity). The font as source for generation is always the same.
Is this normal behavior?
Can the generation be constant with constant input values ​​to the generator?

dataset download

There is some issue with the downloading of the dataset. The downloading is too slow and stops after some time. I think there is some issue on the server side.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.