PyTorch Implementation of Exploring Explicit Domain Supervision for Latent Space Disentanglement in Unpaired Image-to-Image Translation.

Overview

DosGAN-PyTorch

PyTorch Implementation of Exploring Explicit Domain Supervision for Latent Space Disentanglement in Unpaired Image-to-Image Translation.

Dependency:

Python 2.7

PyTorch 0.4.0

Usage:

Multiple identity translation

  1. Downloading Facescrub dataset following http://www.vintage.winklerbros.net/facescrub.html, and save it to root_dir.

  2. Splitting training and testing sets into train_dir and val_dir:

    $ python split2train_val.py root_dir train_dir val_dir

  3. Train a classifier for domain feature extraction and save it to dosgan_cls:

    $ python main_dosgan.py --mode cls --model_dir dosgan_cls --train_data_path train_dir --test_data_path val_dir

  4. Train DosGAN:

    $ python main_dosgan.py --mode train --model_dir dosgan --cls_save_dir dosgan_cls/models --train_data_path train_dir --test_data_path val_dir

  5. Train DosGAN-c:

    $ python main_dosgan.py --mode train --model_dir dosgan_c --cls_save_dir dosgan_cls/models --non_conditional false --train_data_path train_dir --test_data_path val_dir

  6. Test DosGAN:

    $ python main_dosgan.py --mode test --model_dir dosgan_c --cls_save_dir dosgan_cls/models --train_data_path train_dir --test_data_path val_dir

  7. Test DosGAN-c:

    $ python main_dosgan.py --mode test --model_dir dosgan_c --cls_save_dir dosgan_cls/models --non_conditional false --train_data_path train_dir --test_data_path val_dir

Other mutliple domain translation

  1. For other kinds of dataset, you can place train set and test set like:

    data
    ├── YOUR_DATASET_train_dir
        ├── damain1
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ├── domain2
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ├── domain3
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ...
    
    data
    ├── YOUR_DATASET_val_dir
        ├── damain1
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ├── domain2
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ├── domain3
        |   ├── 1.jpg
        |   ├── 2.jpg
        |   └── ...
        ...
    
  2. Giving multiple season translation for example (season dataset). Train a classifier for season domain feature extraction and save it to dosgan_season_cls:

    $ python main_dosgan.py --mode cls --model_dir dosgan_season_cls --ft_num 64 --c_dim 4 --image_size 256 --train_data_path season_train_dir --test_data_path season_val_dir

  3. Train DosGAN for multiple season translation:

    $ python main_dosgan.py --mode train --model_dir dosgan_season --cls_save_dir dosgan_season_cls/models --ft_num 64 --c_dim 4 --image_size 256 --lambda_fs 0.15 --num_iters 300000 --train_data_path season_train_dir --test_data_path season_val_dir

Results:

1. Multiple identity translation

# Results of DosGAN:

# Results of DosGAN-c:

2. Multiple season translation:

You might also like...
Official implementation of the paper DeFlow: Learning Complex Image Degradations from Unpaired Data with Conditional Flows
Official implementation of the paper DeFlow: Learning Complex Image Degradations from Unpaired Data with Conditional Flows

DeFlow: Learning Complex Image Degradations from Unpaired Data with Conditional Flows Official implementation of the paper DeFlow: Learning Complex Im

FuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space OptimizationFuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space Optimization
FuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space OptimizationFuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space Optimization

FuseDream This repo contains code for our paper (paper link): FuseDream: Training-Free Text-to-Image Generation with Improved CLIP+GAN Space Optimizat

Official PyTorch Implementation for InfoSwap: Information Bottleneck Disentanglement for Identity Swapping
Official PyTorch Implementation for InfoSwap: Information Bottleneck Disentanglement for Identity Swapping

InfoSwap: Information Bottleneck Disentanglement for Identity Swapping Code usage Please check out the user manual page. Paper Gege Gao, Huaibo Huang,

Generating images from caption and vice versa via CLIP-Guided Generative Latent Space Search

CLIP-GLaSS Repository for the paper Generating images from caption and vice versa via CLIP-Guided Generative Latent Space Search An in-browser demo is

Navigating StyleGAN2 w latent space using CLIP
Navigating StyleGAN2 w latent space using CLIP

Navigating StyleGAN2 w latent space using CLIP an attempt to build sth with the official SG2-ADA Pytorch impl kinda inspired by Generating Images from

Disentangled Face Attribute Editing via Instance-Aware Latent Space Search, accepted by IJCAI 2021.

Instance-Aware Latent-Space Search This is a PyTorch implementation of the following paper: Disentangled Face Attribute Editing via Instance-Aware Lat

[CVPR 2020] Interpreting the Latent Space of GANs for Semantic Face Editing
[CVPR 2020] Interpreting the Latent Space of GANs for Semantic Face Editing

InterFaceGAN - Interpreting the Latent Space of GANs for Semantic Face Editing Figure: High-quality facial attributes editing results with InterFaceGA

PULSE: Self-Supervised Photo Upsampling via Latent Space Exploration of Generative Models
PULSE: Self-Supervised Photo Upsampling via Latent Space Exploration of Generative Models

PULSE: Self-Supervised Photo Upsampling via Latent Space Exploration of Generative Models Code accompanying CVPR'20 paper of the same title. Paper lin

MODALS: Modality-agnostic Automated Data Augmentation in the Latent Space

Update (20 Jan 2020): MODALS on text data is avialable MODALS MODALS: Modality-agnostic Automated Data Augmentation in the Latent Space Table of Conte

Comments
  • test error

    test error

    1 main_dosgan.py --mode cls --model_dir dosgan_season_cls --ft_num 64 --c_dim 4 --image_size 256 --train_data_path data/season_train_dir --test_data_path data/season_val_dir`

    2 main_dosgan.py --mode train --model_dir dosgan_season --cls_save_dir dosgan_season_cls/models --ft_num 64 --c_dim 4 --image_size 256 --lambda_fs 0.15 --num_iters 300000 --train_data_path season_train_dir --test_data_path season_val_dir`

    3E:\Users\Raytine\Anaconda3\python.exe F:/imageedit/DosGAN-PyTorch-master/main_dosgan.py --mode test --model_dir dosgan_season --cls_save_dir dosgan_season_cls/models --train_data_path data/season_train_dir --test_data_path data/season_val_dir Namespace(batch_size=6, beta1=0.5, beta2=0.999, c_dim=531, cls_save_dir='dosgan_season_cls/models', d_conv_dim=64, d_lr=0.0001, d_repeat_num=6, ft_num=1024, g_lr=0.0001, image_size=128, lambda_fs=5, lambda_gp=10, lambda_rec=10, lambda_rec2=10, log_step=1000, lr_update_step=1000, mode='test', model_dir='dosgan_season', model_save_step=20000, n_blocks=0, n_critic=5, non_conditional=True, num_iters=200000, num_iters_decay=100000, num_workers=1, resume_iters=None, sample_step=2000, test_data_path='data/season_val_dir', test_iters=200000, train_data_path='data/season_train_dir') train dataset loaded test dataset loaded Traceback (most recent call last): File "F:/imageedit/DosGAN-PyTorch-master/main_dosgan.py", line 118, in main(config) File "F:/imageedit/DosGAN-PyTorch-master/main_dosgan.py", line 64, in main solver.test1() File "F:\imageedit\DosGAN-PyTorch-master\solver_dosgan.py", line 611, in test1 self.C.load_state_dict(torch.load(C_path, map_location=lambda storage, loc: storage)) File "E:\Users\Raytine\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 719, in load_state_dict self.class.name, "\n\t".join(error_msgs))) RuntimeError: Error(s) in loading state_dict for Classifier: size mismatch for conv1.0.bias: copying a param of torch.Size([1024]) from checkpoint, where the shape is torch.Size([64]) in current model. size mismatch for conv1.0.weight: copying a param of torch.Size([1024, 2048, 2, 2]) from checkpoint, where the shape is torch.Size([64, 2048, 4, 4]) in current model. size mismatch for conv2.weight: copying a param of torch.Size([531, 1024, 1, 1]) from checkpoint, where the shape is torch.Size([4, 64, 1, 1]) in current model.

    opened by c1a1o1 1
  • 未能复现原文结果。

    未能复现原文结果。

    您好: 非常感谢您在图像翻译领域做的贡献,对我帮助良多。最近,在复现您的DosGAN论文的时候,我复现的是多身份翻译,根据说明文档,下载了facescrub数据集,先划分数据集,然后训练cls,然后train,最后test,各相关参数与您的设定一致,但最后的图像却没有任何改变,请问我需要调整某些参数吗? 期待您的回复,非常感谢。 10_x_AB_results

    opened by zhangqian001 0
  • 关于在训练和测试时身份域数量的问题。

    关于在训练和测试时身份域数量的问题。

    作者您好,非常感谢您在图像翻译方面做的贡献。我现在有这么一些问题。 1、我下载的facescrub数据集只有256个身份,所以在main_dosgan.py文件中我的c_dim设置为256。但是在测试时候不改的话,生成图像的尺寸就是(257*128)*128,就非常的大。如果把c_dim改为4或者8,程序就会报错。想问下您有什么好的建议吗。 2、如果我自己采集数据集的话,每个身份放多少图像合适呢?,具体要多少身份,这会对模型的精度造成很大影响吗? 期待您的回复,谢谢。 祝您身体健康,工作顺利。

    opened by zhangqian001 0
Owner
Ph.D. Candidate of University of Science and Technology of China
null
Minimal PyTorch implementation of Generative Latent Optimization from the paper "Optimizing the Latent Space of Generative Networks"

Minimal PyTorch implementation of Generative Latent Optimization This is a reimplementation of the paper Piotr Bojanowski, Armand Joulin, David Lopez-

Thomas Neumann 117 Nov 27, 2022
An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020

UnpairedSR An unofficial implementation of "Unpaired Image Super-Resolution using Pseudo-Supervision." CVPR2020 turn RCAN(modified) --> xmodel(xilinx

JiaKui Hu 10 Oct 28, 2022
Official pytorch implementation of paper "Image-to-image Translation via Hierarchical Style Disentanglement".

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

null 364 Dec 14, 2022
Official pytorch implementation of "Scaling-up Disentanglement for Image Translation", ICCV 2021.

Official pytorch implementation of "Scaling-up Disentanglement for Image Translation", ICCV 2021.

Aviv Gabbay 41 Nov 29, 2022
Code of 3D Shape Variational Autoencoder Latent Disentanglement via Mini-Batch Feature Swapping for Bodies and Faces

3D Shape Variational Autoencoder Latent Disentanglement via Mini-Batch Feature Swapping for Bodies and Faces Installation After cloning the repo open

null 37 Dec 3, 2022
PyTorch implementation of the WarpedGANSpace: Finding non-linear RBF paths in GAN latent space (ICCV 2021)

Authors official PyTorch implementation of the "WarpedGANSpace: Finding non-linear RBF paths in GAN latent space" [ICCV 2021].

Christos Tzelepis 100 Dec 6, 2022
Learning trajectory representations using self-supervision and programmatic supervision.

Trajectory Embedding for Behavior Analysis (TREBA) Implementation from the paper: Jennifer J. Sun, Ann Kennedy, Eric Zhan, David J. Anderson, Yisong Y

null 58 Jan 6, 2023
Mixup for Supervision, Semi- and Self-Supervision Learning Toolbox and Benchmark

OpenSelfSup News Downstream tasks now support more methods(Mask RCNN-FPN, RetinaNet, Keypoints RCNN) and more datasets(Cityscapes). 'GaussianBlur' is

AI Lab, Westlake University 332 Jan 3, 2023
Exploring Image Deblurring via Blur Kernel Space (CVPR'21)

Exploring Image Deblurring via Encoded Blur Kernel Space About the project We introduce a method to encode the blur operators of an arbitrary dataset

VinAI Research 118 Dec 19, 2022
Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

HamasKhan 3 Jul 8, 2022