3neutronstar / ACGAN-PyTorch

Unofficial Auxiliary Classifier GAN implementation (based on https://github.com/clvrai/ACGAN-PyTorch)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conditional Image Synthesis With Auxiliary Classifier GANs

This project is a PyTorch implementation of Conditional Image Synthesis With Auxiliary Classifier GANs. This project is from ACGAN-PyTorch. Just fix the code for implementing correctly.
(PyTorch version 0.4 -> 1.8 is available)
Also, add the image generation code generate_image.py, if the checkpoint exists.

Prerequisites

Usage

Run the following command for details of each arguments.

$ python main.py -h

You should specify the path to the dataset you are using with argument --dataroot, the code will automatically check if you have cifar10 dataset downloaded or not. If not, the code will download it for you. For the ImageNet training you should download the whole dataset on their website, this repository used 2012 version for the training. And you should point the dataroot to the train (or val) directory as the root directory for ImageNet training.

In line 80 of main.py, you can change the classes_idx argument to take into other user-specified imagenet classes, and adjust the num_classes accordingly if it is not 10.

if opt.dataset == 'imagenet':
    # folder dataset
    dataset = ImageFolder(root=opt.dataroot,
                          transform=transforms.Compose([
                              transforms.Scale(opt.imageSize),
                              transforms.CenterCrop(opt.imageSize),
                              transforms.ToTensor(),
                              transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
                         ]),
                         classes_idx=(10,20))

Train the models

Example training commands, the code will automatically generate images for testing during training to the --outf directory.

$ python main.py --niter=500 --batchSize=100 --cuda --dataset=cifar10 --imageSize=32 --dataroot=/data/path/to/cifar10 --gpu=0

Extract learning images

    python generate_image.py --eval_epoch=/epoch/you/want --cuda --dataset=cifar10 --dataroot=/data/path/to/cifar10 --gpu=0 

Examples

The sample generated images from ImageNet dataset.

The sample generated images from CIFAR-10 dataset.

About

Unofficial Auxiliary Classifier GAN implementation (based on https://github.com/clvrai/ACGAN-PyTorch)

License:MIT License


Languages

Language:Python 100.0%