All Projects → imlixinyang → Hisd

imlixinyang / Hisd

Licence: other
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement" (CVPR 2021 Oral).

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Hisd

Tsit
[ECCV 2020 Spotlight] A Simple and Versatile Framework for Image-to-Image Translation
Stars: ✭ 141 (-4.73%)
Mutual labels:  gan
Art Dcgan
Modified implementation of DCGAN focused on generative art. Includes pre-trained models for landscapes, nude-portraits, and others.
Stars: ✭ 1,882 (+1171.62%)
Mutual labels:  gan
Tensorflow Infogan
🎎 InfoGAN: Interpretable Representation Learning
Stars: ✭ 149 (+0.68%)
Mutual labels:  gan
Glcic Pytorch
A High-Quality PyTorch Implementation of "Globally and Locally Consistent Image Completion".
Stars: ✭ 141 (-4.73%)
Mutual labels:  gan
Unit
Unsupervised Image-to-Image Translation
Stars: ✭ 1,809 (+1122.3%)
Mutual labels:  gan
Lr Gan.pytorch
Pytorch code for our ICLR 2017 paper "Layered-Recursive GAN for image generation"
Stars: ✭ 145 (-2.03%)
Mutual labels:  gan
Human Video Generation
Human Video Generation Paper List
Stars: ✭ 139 (-6.08%)
Mutual labels:  gan
Shapegan
Generative Adversarial Networks and Autoencoders for 3D Shapes
Stars: ✭ 151 (+2.03%)
Mutual labels:  gan
Tensorflow Pix2pix
A lightweight pix2pix Tensorflow implementation.
Stars: ✭ 143 (-3.38%)
Mutual labels:  gan
Pix2pixbegan.pytorch
A pytorch implementation of pix2pix + BEGAN (Boundary Equilibrium Generative Adversarial Networks)
Stars: ✭ 148 (+0%)
Mutual labels:  gan
Starnet
StarNet
Stars: ✭ 141 (-4.73%)
Mutual labels:  gan
Pix2latent
Code for: Transforming and Projecting Images into Class-conditional Generative Networks
Stars: ✭ 141 (-4.73%)
Mutual labels:  gan
P2pala
Page to PAGE Layout Analysis Tool
Stars: ✭ 147 (-0.68%)
Mutual labels:  gan
Data science blogs
A repository to keep track of all the code that I end up writing for my blog posts.
Stars: ✭ 139 (-6.08%)
Mutual labels:  gan
Stylegan.pytorch
A PyTorch implementation for StyleGAN with full features.
Stars: ✭ 150 (+1.35%)
Mutual labels:  gan
Focal Frequency Loss
Focal Frequency Loss for Generative Models
Stars: ✭ 141 (-4.73%)
Mutual labels:  gan
Face generator
DCGAN face generator 🧑.
Stars: ✭ 146 (-1.35%)
Mutual labels:  gan
Mask guided portrait editing
pytorch implementation of "Mask-Guided Portrait Editing with Conditional GANs"
Stars: ✭ 155 (+4.73%)
Mutual labels:  gan
Pytorch Gan
A minimal implementaion (less than 150 lines of code with visualization) of DCGAN/WGAN in PyTorch with jupyter notebooks
Stars: ✭ 150 (+1.35%)
Mutual labels:  gan
Person Reid Gan Pytorch
A Pytorch Implementation of "Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro"(ICCV17)
Stars: ✭ 147 (-0.68%)
Mutual labels:  gan

License CC BY-NC-SA 4.0

HiSD: Image-to-image Translation via Hierarchical Style Disentanglement

Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

fig

HiSD is the SOTA image-to-image translation method for both Scalability for multiple labels and Controllable Diversity with impressive disentanglement.

The styles to manipolate each tag in our method can be not only generated by random noise but also extracted from images!

Also, the styles can be smoothly interpolated like:

reference

All tranlsations are producted be a unified HiSD model and trained end-to-end.

!News:

[2021.3.11]: High-resolution (256x256) config and checkpoint released.

I will release a checkpoint of six tags (Bangs, Glasses, Hair color, Smile, Beard and Age) later.

Easy Use (for Both Jupyter Notebook and Python Script)

Download the pretrained checkpoint in Baidu Drive (Password:wgdx) or Google Drive. Then put it into the root of this repo.

Open "easy_use.ipynb" and you can manipolate the facial attributes by yourself!

If you haven't installed Jupyter, use "easy_use.py".

The script will translate "examples/input_0.jpg" to be with bangs generated by a random noise and glasses extracted from "examples/reference_glasses_0.jpg"

Quick Start

Clone this repo:

git clone https://github.com/imlixinyang/HiSD.git
cd HiSD/

Install the dependencies: (Anaconda is recommended.)

conda create -n HiSD python=3.6.6
conda activate HiSD
conda install -y pytorch=1.0.1 torchvision=0.2.2  cudatoolkit=10.1 -c pytorch
pip install pillow tqdm tensorboardx pyyaml

Download the dataset.

We recommend you to download CelebA-HQ from CelebAMask-HQ. Anyway you shound get the dataset folder like:

celeba_or_celebahq
 - img_dir
   - img0
   - img1
   - ...
 - train_label.txt

Preprocess the dataset.

In our paper, we use fisrt 3000 as test set and remaining 27000 for training. Carefully check the fisrt few (always two) lines in the label file which is not like the others.

python proprecessors/celeba-hq.py --img_path $your_image_path --label_path $your_label_path --target_path datasets --start 3002 --end 30002

Then you will get several ".txt" files in the "datasets/", each of them consists of lines of the absolute path of image and its tag-irrelevant conditions (Age and Gender by default).

Allmost all custom datasets can be converted into special cases of HiSD. We provide a script for custom datasets. You need to organize the folder like:

your_training_set
 - Tag0
   - attribute0
     - img0
     - img1
     - ...
   - attribute1
     - ...
 - Tag1
 - ...

For example, the AFHQ (one tag and three attributes, remember to split the training and test set first):

AFHQ_training
  - Category
    - cat
      - img0
      - img1
      - ...
    - dog
      - ...
    - wild
      - ...

You can Run

python proprecessors/custom.py --imgs $your_training_set --target_path datasets/custom.txt

For other datasets, please code the preprocessor by yourself.

Here, we provide some links for you to download other available datasets:

Dataset in Bold means we have tested the generalization of HiSD for this dataset.

Train.

Following "configs/celeba-hq.yaml" to make the config file fit your machine and dataset.

For a single 1080Ti and CelebA-HQ, you can directly run:

python core/train.py --config configs/celeba-hq.yaml --gpus 0

The samples and checkpoints are in the "outputs/" dir. For Celeba-hq dataset, the samples during first 200k iterations will be like: (tag 'Glasses' to attribute 'with')

training

Test.

Modify the 'steps' dict in the first few lines in 'core/test.py' and run:

python core/test.py --config configs/celeba-hq.yaml --checkpoint $your_checkpoint --input_path $your_input_path --output_path results

$your_input_path can be either a image file or a folder of images. Default 'steps' make every image to be with bangs and glasses using random latent-guided styles.

Evaluation metrics.

We use FID for quantitative comparison. For more details, please refer to the paper.

License

Licensed under the CC BY-NC-SA 4.0 (Attribution-NonCommercial-ShareAlike 4.0 International)

The code is released for academic research use only. For other use, please contact me at [email protected].

Citation

If our paper helps your research, please cite it in your publications:

@article{li2021imagetoimage,
      title={Image-to-image Translation via Hierarchical Style Disentanglement}, 
      author={Xinyang Li and Shengchuan Zhang and Jie Hu and Liujuan Cao and Xiaopeng Hong and Xudong Mao and Feiyue Huang and Yongjian Wu and Rongrong Ji},
      journal={arXiv preprint arXiv:2011.13084},
      year={2020}
}

I try my best to make the code easy to understand or further modified because I feel very lucky to start with the clear and readily comprehensible code of MUNIT when I'm a beginner.

If you have any problem, please feel free to contact me at [email protected] or raise an issue.

Related Work

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].