Skip to content

Latest commit

 

History

History
202 lines (136 loc) · 10.9 KB

README.md

File metadata and controls

202 lines (136 loc) · 10.9 KB

ACGAN-Paddle

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 samples real 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 imagesREADME.md                      # English readmeREADME_cn.md                   # Chinese readmedataset.py                     # Class for datasetnetwork.py                     # Architecture for modeltrain.py                       # Training scripttest.py                        # Testing scriptutils.py                       # Tool classes

6.2 description

  • train.py parameter description

    Parameters Default Description
    --dataroot str: ‘/media/gallifrey/DJW/Dataset/Imagenet/train’ Path for training set
    --workers int : 4 Number of threads
    --batchSize int: 100 Start checkpoint
    --imageSize int: 128 Size of load / generate images
    --nz int: 110 Dimension for latent
    --ngf int: 64 Scale for channels of G
    --ndf int: 5 Scale for channels of D
    --lr float: 0.0002 Initial learning rate
    --beta1 float: 0.5 Beta param for optimizer
    --check_path str: './checkpoints' Path for chekpoints
    --result_path str:'./result' Path for results
    --log_path str: './log' Path for log file
    --save_freq int: 5 Save frequency
    --num_classes int: 10 Number of clasess
    --niter int: 500 Number of training epoches
  • test.py parameter description

    Parameters Default Description
    --batchSize int: 100 Number of samole for testing one batch
    --nz int: 110 Dimension of latent
    --check_path str: './checkpoints' Path for checkpoints
    --imageSize int: 128 Size of load / generate images
    --result_path str:'./result' Path for results
    --num_classes int: 10 Number of classes
    --which_epoch int: 499 IModel ID for testing

7. Results

7.1 Training loss (class id 10-20)

Accuracy D Loss G Loss

7.2 Visual Comparison

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

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

8. Model Information

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

Information Description
Author Dai Jiawu
Date 2021.09
Framework version Paddle 2.0.2
Application scenarios Image Generation
Supported Hardware GPU、CPU
Download link Pre-trained models (code:ce8r)
Online operation Scripts