Git Product home page Git Product logo

pytorch-srgan's Introduction

PyTorch-SRGAN

A modern PyTorch implementation of SRGAN

It is deeply based on Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network paper published by the Twitter team (https://arxiv.org/abs/1609.04802) but I replaced activations by Swish (https://arxiv.org/abs/1710.05941)

You can start training out-of-the-box with the CIFAR-10 or CIFAR-100 datasets, to emulate the paper results however, you will need to download and clean the ImageNet dataset yourself. Results and weights are provided for the ImageNet dataset.

Contributions are welcome!

Requirements

Training

usage: train [-h] [--dataset DATASET] [--dataroot DATAROOT]
             [--workers WORKERS] [--batchSize BATCHSIZE]
             [--imageSize IMAGESIZE] [--upSampling UPSAMPLING]
             [--nEpochs NEPOCHS] [--generatorLR GENERATORLR]
             [--discriminatorLR DISCRIMINATORLR] [--cuda] [--nGPU NGPU]
             [--generatorWeights GENERATORWEIGHTS]
             [--discriminatorWeights DISCRIMINATORWEIGHTS] [--out OUT]

Example: ./train --cuda

This will start a training session in the GPU. First it will pre-train the generator using MSE error for 2 epochs, then it will train the full GAN (generator + discriminator) for 100 epochs, using content (mse + vgg) and adversarial loss. Although weights are already provided in the repository, this script will also generate them in the checkpoints file.

Testing

usage: test [-h] [--dataset DATASET] [--dataroot DATAROOT] [--workers WORKERS]
            [--batchSize BATCHSIZE] [--imageSize IMAGESIZE]
            [--upSampling UPSAMPLING] [--cuda] [--nGPU NGPU]
            [--generatorWeights GENERATORWEIGHTS]
            [--discriminatorWeights DISCRIMINATORWEIGHTS]

Example: ./test --cuda

This will start a testing session in the GPU. It will display mean error values and save the generated images in the output directory, all three versions: low resolution, high resolution (original) and high resolution (generated).

Results

Training

The following results have been obtained with the current training setup:

  • Dataset: 350K randomly selected ImageNet samples
  • Input image size: 24x24
  • Output image size: 96x96 (16x)

Other training parameters are the default of train script

Tensorboard training graphs

Testing

Testing has been executed on 128 randomly selected ImageNet samples (disjoint from training set)

[7/8] Discriminator_Loss: 1.4123 Generator_Loss (Content/Advers/Total): 0.0901/0.6152/0.0908

Examples

See more under the output directory

High resolution / Low resolution / Recovered High Resolution

Original doggy Low res doggy Generated doggy

Original woman Low res woman Generated woman

Original hair Low res hair Generated hair

Original sand Low res sand Generated sand

pytorch-srgan's People

Contributors

aitorzip avatar

Watchers

 avatar

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.