ACGAN-Paddle

September 27, 2021 · View on GitHub

English| 简体中文

1. Introduction

Architecture

This project is based on the PaddlePaddle replication paper "Conditional Image Synthesis with Auxiliary Classifier GANs"(ACGAN), which focuses on adding an auxiliary discriminator to a conditional generative adversarial network (Conditional GAN) to guide the image generation process. The main work of this paper is to add an auxiliary discriminator to conditional generative adversarial networks (CGAs) to guide the image generation process by adding a classification layer to the discriminator of the model to force the generated image classes to be as close as possible to the input labels. Experimentally, ACGAN has been shown to perform well in synthesizing high-resolution images.

Paper

  • [[1] Odena, A. , C. Olah , and J. Shlens . "Conditional Image Synthesis With Auxiliary Classifier GANs." (2016).

Projects

Since the authors did not release the source code, the following unofficial implementation was referenced for this project.

Online Operation

2. Accuracy

This replication did not involve metrics measurement, and the main goal was to generate images that could be close to the real sample in terms of visual assessment, so the following shows the randomly generated sample and the real sample.

fake samplesreal samples

3. Dataset

The dataset in the paper is ImageNet, and the dataset is organized in the following format.

  • Training set: 1279591 images
  • Validation set: 50000 images
  • Testing set: 10000 images

According to the setup in the paper, 1000 image categories are grouped and one group of 10 categories is used to train a model. Three different sets of experiments were performed for this replication.

  • 10,000 images of image category number 10-20 as the training set
  • 10,000 images of image category number 100-100 as training set
  • Randomly selected 10 categories with 10,000 images as the training set

4. Dependency

  • Hardware:GPU、CPU
  • Framework:PaddlePaddle>=2.0.0

5. Quick Start

Clone

git https://github.com/Callifrey/ACGAN-Paddle.git
cd ACGAN-Paddle

Training

python trian.py --dataroot [imagenet path] # [eg:xxx/ImageNet/train]

Testing

python test.py --check_path [checkpoints path] --which_epoch [epoch]

Check Log

visuldl --logdir ./log

Prediction with pre-trained models

The pre-training model is available at Baidu Drive( Extraction code: ce8r ) where there are three files in each folder, which are the generator model parameters, the discriminator model parameters and the log corresponding to the group of experiments, please place the pre-training model in checkpoints directory, and set the path of the corresponding folder when testing.

6. Code structure and description

6.1 code structure

├─checkpoints                     # dir for saving models
├─imgs                            # dir for saving images
├─log                             # logging files
├─results                         # dir for generated images
README.md                      # English readme
README_cn.md                   # Chinese readme
│  dataset.py                     # Class for dataset
│  network.py                     # Architecture for model
│  train.py                       # Training script
│  test.py                        # Testing script
│  utils.py                       # Tool classes

6.2 description

  • train.py parameter description

    ParametersDefaultDescription
    --datarootstr: ‘/media/gallifrey/DJW/Dataset/Imagenet/train’Path for training set
    --workersint : 4Number of threads
    --batchSizeint: 100Start checkpoint
    --imageSizeint: 128Size of load / generate images
    --nzint: 110Dimension for latent
    --ngfint: 64Scale for channels of G
    --ndfint: 5Scale for channels of D
    --lrfloat: 0.0002Initial learning rate
    --beta1float: 0.5Beta param for optimizer
    --check_pathstr: './checkpoints'Path for chekpoints
    --result_pathstr:'./result'Path for results
    --log_pathstr: './log'Path for log file
    --save_freqint: 5Save frequency
    --num_classesint: 10Number of clasess
    --niterint: 500Number of training epoches
  • test.py parameter description

    ParametersDefaultDescription
    --batchSizeint: 100Number of samole for testing one batch
    --nzint: 110Dimension of latent
    --check_pathstr: './checkpoints'Path for checkpoints
    --imageSizeint: 128Size of load / generate images
    --result_pathstr:'./result'Path for results
    --num_classesint: 10Number of classes
    --which_epochint: 499IModel ID for testing

7. Results

7.1 Training loss (class id 10-20)

AccuracyD LossG Loss

7.2 Visual Comparison

  • Fake samples VS Real samples
Fake samples(Ours)Fake samples(ACGAN-Pytorch)Real samples
  • More results

    ClassFake samples 1Fake samples 2Fake samples 3Real samples
    Classes 100-110
    Random 10 classes

8. Model Information

Additional information about the model can be found in the following table:

InformationDescription
AuthorDai Jiawu
Date2021.09
Framework versionPaddle 2.0.2
Application scenariosImage Generation
Supported HardwareGPU、CPU
Download linkPre-trained models (code:ce8r)
Online operationScripts