Unpaired Portrait Drawing Jittor Implementation
April 13, 2021 ยท View on GitHub
We provide Jittor implementations for our CVPR 2020 paper "Unpaired Portrait Drawing Generation via Asymmetric Cycle Mapping". paper, suppl.
This project generates multi-style artistic portrait drawings from face photos using a GAN-based model.
Prerequisites
- Linux or macOS
- Python 3
- CPU or NVIDIA GPU + CUDA CuDNN
Sample Results
From left to right: input, output(style1), output(style2), output(style3)

Installation
- To install the dependencies, run
pip install -r requirements.txt
Apply pretrained model
-
- Download pre-trained models from BaiduYun(extract code:c9h7) or GoogleDrive and rename the folder to
checkpoints.
- Download pre-trained models from BaiduYun(extract code:c9h7) or GoogleDrive and rename the folder to
-
- Test for example photos: generate artistic portrait drawings for example photos in the folder
./samplesusing
- Test for example photos: generate artistic portrait drawings for example photos in the folder
python test.py --input_folder ./samples
Results are saved in ./results/portrait_drawing/pretrained_200
-
- To test on your own photos: First use an image editor to crop the face region of your photo (or use an optional preprocess here). Then specify the folder that contains test photos using option
--input_folder, and run thetest.pyagain.
- To test on your own photos: First use an image editor to crop the face region of your photo (or use an optional preprocess here). Then specify the folder that contains test photos using option
Train
-
- Prepare for the dataset: 1) download face photos and portrait drawings from internet (e.g. resources). 2) align, crop photos and drawings & 3) prepare nose, eyes, lips masks according to preprocess instructions. 3) put aligned photos under
./data/portrait_drawing/train/A, aligned drawings under./data/portrait_drawing/train/B, masks underA_nose,A_eyes,A_lips,B_nose,B_eyes,B_lipsrespectively.
- Prepare for the dataset: 1) download face photos and portrait drawings from internet (e.g. resources). 2) align, crop photos and drawings & 3) prepare nose, eyes, lips masks according to preprocess instructions. 3) put aligned photos under
-
- Train a 3-class style classifier and extract the 3-dim style feature (according to paper). And save the style feature of each drawing in the training set in .npy format, in folder
./data/portrait_drawing/train/B_feat
- Train a 3-class style classifier and extract the 3-dim style feature (according to paper). And save the style feature of each drawing in the training set in .npy format, in folder
A subset of our training set is here.
-
- Train our model (200 epochs)
python asymmetric_cyclegan.py
Models are saved in folder checkpoints/portrait_drawing
-
- Test the trained model
python test.py --which_epoch 200 --model_name portrait_drawing
Results are saved in ./results/portrait_drawing/portrait_drawing_200
Citation
If you use this code for your research, please cite our paper.
@inproceedings{YiLLR20,
title = {Unpaired Portrait Drawing Generation via Asymmetric Cycle Mapping},
author = {Yi, Ran and Liu, Yong-Jin and Lai, Yu-Kun and Rosin, Paul L},
booktitle = {{IEEE} Conference on Computer Vision and Pattern Recognition (CVPR '20)},
pages = {8214--8222},
year = {2020}
}