Code Monkey home page Code Monkey logo

stgan-pytorch's Introduction

STGAN (CVPR 2019)

An unofficial PyTorch implementation of STGAN: A Unified Selective Transfer Network for Arbitrary Image Attribute Editing.

Requirements

Sample

From left to right: Origin, Bangs, Blond_Hair, Brown_Hair, Bushy_Eyebrows, Eyeglasses, Male, Mouth_Slightly_Open, Mustache, Pale_Skin, Young.

Preparation

Please download the CelebA dataset from this project page. Then organize the directory as:

├── data_root
│   └── image
│       ├── 000001.jpg
│       ├── 000002.jpg
│       ├── 000003.jpg
│       └── ...
│   └── anno
│       ├── list_attr_celeba.txt
│       └── ...

Training

  • For quickly start, you can simply use the following command to train:

    CUDA_VISIBLE_DEVICES=0,1,2,3 python main.py --config ./configs/train_stgan.yaml
  • If you want to modify some hyper-parameters, please edit them in the configuration file ./configs/train_stgan.yaml following the explanations below:

    • exp_name: the name of current experiment.
    • mode: 'train' or 'test'.
    • cuda: use CUDA or not.
    • ngpu: how many gpu cards to use. Notice: this number should be no more than the length of CUDA_VISIBLE_DEVICES list.
    • dataset: the name of dataset. Notice: you can extend other datasets.
    • data_root: the root of dataset.
    • crop_size: the crop size of images.
    • image_size: the size of input images during training.
    • g_conv_dim: the base filter numbers of convolutional layers in G.
    • d_conv_dim: the base filter numbers of convolutional layers in D.
    • d_fc_dim: the dimmension of fully-connected layers in D.
    • g_layers: the number of convolutional layers in G. Notice: same for both encoder and decoder.
    • d_layers: the number of convolutional layers in D.
    • shortcut_layers: the number of shortcut connections in G. Notice: also the number of STUs.
    • stu_kernel_size: the kernel size of convolutional layers in STU.
    • use_stu: if set to false, there will be no STU in shortcut connections.
    • one_more_conv: if set to true, there will be another convolutional layer between the decoder and generated image.
    • attrs: the list of all selected atrributes. Notice: please refer to list_attr_celeba.txt for all avaliable attributes.
    • checkpoint: the iteration step number of the checkpoint to be resumed. Notice: please set this to ~ if it's first time to train.
    • batch_size: batch size of data loader.
    • beta1: beta1 value of Adam optimizer.
    • beta2: beta2 value of Adam optimizer.
    • g_lr: the base learning rate of G.
    • d_lr: the base learning rate of D.
    • n_critic: number of D updates per each G update.
    • thres_int: the threshold of target vector during training.
    • lambda_gp: tradeoff coefficient of D_loss_gp.
    • lambda1: tradeoff coefficient of D_loss_att.
    • lambda2: tradeoff coefficient of G_loss_att.
    • lambda3: tradeoff coefficient of G_loss_rec.
    • max_iters: maximum iteration steps.
    • lr_decay_iters: iteration steps per learning rate decay.
    • summary_step: iteration steps per summary operation with tensorboardX.
    • sample_step: iteration steps per sampling operation.
    • checkpoint_step: iteration steps per checkpoint saving operation.

Acknowledgements

This code refers to the following two projects:

[1] TensorFlow implementation of STGAN

[2] PyTorch implementation of StarGAN

stgan-pytorch's People

Contributors

bluestyle97 avatar esemeniuc 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

Watchers

 avatar  avatar  avatar  avatar

stgan-pytorch's Issues

doesnot run train.py completely.

Hi, can you please help me to run the code completely. whenever i try to run the train.py module, it produce following information and then stop. currently i am trying to run the code in Google colab.

The experiment name is stgan
The experiment mode is train


directory created successfully
[INFO]: Hi, This is root.
[INFO]: After the configurations are successfully processed and dirs are created.
[INFO]: The pipeline of the project will begin now.
[INFO]: Creating STGAN architecture...
[INFO]: Operation will be on GPU-CUDA
[INFO]: __Python VERSION: 3.8.10 (default, Nov 14 2022, 12:59:47)
[GCC 9.4.0]
[INFO]: __PyTorch VERSION: 1.13.1+cu116
[INFO]: __CUDA VERSION
cat: /usr/local/cuda/version.txt: No such file or directory
[INFO]: __CUDNN VERSION: 8302
[INFO]: __Number CUDA Devices: 1
[INFO]: __Devices
index, name, driver_version, memory.total [MiB], memory.used [MiB], memory.free [MiB]
0, Tesla T4, 510.47.03, 15360 MiB, 3 MiB, 15106 MiB
[INFO]: __Active CUDA Device: GPU 0
[INFO]: __Available devices 1
[INFO]: __Current cuda device 0
Please wait while finalizing the operation.. Thank you

how to set model_name

print(' The experiment model is {} '.format(config.model_name))
AttributeError: 'EasyDict' object has no attribute 'model_name'

What does the 'shortcut_layers' mean in the code?

Thank you very much for the code you provided.But there is a question for me.In the stgan.py,I found the 'shortcut_layers' which I couldn't match to the paper,could you please tell me the meaning of it?
Thank you very much.

Is there mode collapse in "add eyeglass" attribute?

thank you very much for this great work.
when I run your code,i find that the results on "add eyeglass" are the same as sources image.
is there mode collapse in "add eyeglass" attribute.
by the way,why does the tensorflow code have a more excellent results than pytorch code?

Why this reimplementation use bias==False in all CONV layers?

Hi, bluestyle97!
Thanks for your nice pytorch reimplementation! It more faster than official version. But, i found some difference: 1. conv without bias . 2. target label has a randmom coefficient multiplied. Could you explain that? I am confusing about why you did this. thank you very much!

test code

i am a pytorch rookie, can you launch the tset file here?
thank you very much

# about training time cost

hello, thanks for your sharing. Could you please tell me how much time this project cost ? several days ? and how many GPUS you used?

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.