GitXplorerGitXplorer
h

CalligraphyGAN

public
13 stars
0 forks
1 issues

Commits

List of commits on branch master.
Verified
67fb854cf0d04f9bdd527325bdea34ad8390b76f

Merge pull request #20 from zhuojg/master

hharrywang committed 4 years ago
Unverified
f7aabad1684b6bcf75208554330af47984d5fe54

fix: add cache dir for bert_transformers

zzhuojg committed 4 years ago
Unverified
2a26cb1ad8fc52b3d774e7b97f82ab9d2f223987

fix: update training info show

zzhuojg committed 4 years ago
Unverified
944a46a448082a098fd96a695eec5ddb1bc965dc

fix: add comments and update config for CalligraphyGAN

zzhuojg committed 4 years ago
Unverified
f640faad957e8229a61710cdc56230d1c958d364

feature: add training pipeline

zzhuojg committed 4 years ago
Unverified
e3e8a036390be28c9f7325ac756e893b5e9eef84

fix: add images in readme, change brush_dir in oil_painting and st_demo

zzhuojg committed 4 years ago

README

The README file for this repository.

A Framework and Dataset for Abstract Art Generation via CalligraphyGAN

This is the code for the paper

A Framework and Dataset for Abstract Art Generation via CalligraphyGAN
Jinggang Zhuo, Harry Jiannan Wang, Ling Fan
Presented at NeurIPS Workshop, Machine Learning for Creativity and Design.

paper | demo

We propose a creative framework based on Conditional Generative Adversarial Networks and Contextual Neural Language Model to generate artworks that have intrinsic meaning and aesthetic value.

Input a description in Chinese, and you can get a image representing these Chinese characters.

The whole framework is composed of 3 parts -- CalligraphyGAN, Bert and Oil Painting.

Model

CalligraphyGAN

In this part, we use 1000 Chinese characters in Chinese Calligraphy Dataset as training data to train a generator.
This generator is based on conditional GAN and take a 1000-dimensional vector as input. Each dimension in this vector represents the weight of each Chinese character in the data set.

Bert

adapted based on https://github.com/huggingface/transformers

In this part, we developed a simple algorithm based on BERT to map the input text with arbitrary number of characters into five characters from the 1000 characters used in GAN.

Oil Painting

adapted based on by https://github.com/ctmakro/opencv_playground

In this part, we convert generated image into oil painting.

Setup

Follow the instructions, you can run web demo or train the model on your machine.

Using Docker

Make sure you have Docker installed correctly, and pull the image by

docker pull zhuojg1519/calligraphy.ai

Source code and pretrained model are all included in this image.

Setup on Local

  • Clone the repo and change directory to it
git clone https://github.com/harrywang/calligraphy.ai.git
cd calligraphy.ai
  • Download checkpoint from Google Drive, and move files to calligraphy.ai/ckpt. So, the directory tree should be:
...
├── ckpt
│   ├── ckpt-11.data-00000-of-00001
│   ├── ckpt-11.index
...
  • Setup the virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Running Web Demo

We use Streamlit to implement our web demo.

  • With docker, run the container and expose the port 8501.
docker run -d -p 8501:8501 zhuojg1519/calligraphy.ai
  • On local machine, run st_demo.py with Streamlit.
streamlit run st_demo.py

Then visit localhost:8501 to enjoy it.

Training Model

  • Download 1000 characters we use from Google Drive, and move files to calligraphy.ai/data. So, the directory tree should be:
...
├── data
│   ├── chinese-calligraphy-1000.zip
...
  • Unzip the dataset. Use -O GBK because the folder name is Chinese, and some OS cannot handle it correctly.
unzip -O GBK chinese-calligraphy-1000.zip

Then

  • With docker, specify COMMAND to train in the background, and use docker logs to print logs.

If you want to use GPUs on Linux, make sure you have installed NVIDIA Container Toolkit.

docker run -d -t -v `pwd`:/usr/src/calligraphy-ai --name="calligraphy.ai" zhuojg1519/calligraphy.ai python train.py
docker logs -f calligraphy.ai
  • On local machine, run train.py to start training.
python train.py

You can change training configuration in models/calligraphyGAN_config.py