Coder Social home page Coder Social logo

alan-ai-learner / srgan Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tensorlayer/srgan

0.0 0.0 0.0 148.1 MB

Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network

Home Page: https://github.com/tensorlayer/tensorlayer

Python 100.00%

srgan's Introduction

Super Resolution Examples

πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯Now, we update this script under TensorLayerX!

TensorLayerX: A Unified Deep Learning and Reinforcement Learning Framework for All Hardwares, Backends and OS.

For earlier version, please check srgan release and tensorlayer.

SRGAN Architecture

TensorLayerX Implementation of "Photo-Realistic Single Image Super-Resolution Using a Generative Adversarial Network"

Prepare Data and Pre-trained VGG

    1. You need to download the pretrained VGG19 model weights in here.
    1. You need to have the high resolution images for training.
    • In this experiment, I used images from DIV2K - bicubic downscaling x4 competition, so the hyper-paremeters in config.py (like number of epochs) are seleted basic on that dataset, if you change a larger dataset you can reduce the number of epochs.
    • If you dont want to use DIV2K dataset, you can also use Yahoo MirFlickr25k, just simply download it using train_hr_imgs = tl.files.load_flickr25k_dataset(tag=None) in main.py.
    • If you want to use your own images, you can set the path to your image folder via config.TRAIN.hr_img_path in config.py.

Run

πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯ You need install TensorLayerX at first!

πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯πŸ”₯ Please install TensorLayerX via source

pip install git+https://github.com/tensorlayer/tensorlayerx.git 

Train

config.TRAIN.img_path = "your_image_folder/"

Your directory structure should look like this:

srgan/
    └── config.py
    └── srgan.py
    └── train.py
    └── vgg.py
    └── model
          └── vgg19.npy
    └── DIV2K
          └── DIV2K_train_HR
          β”œβ”€β”€ DIV2K_train_LR_bicubic
          β”œβ”€β”€ DIV2K_valid_HR
          └── DIV2K_valid_LR_bicubic

  • Start training.
python train.py

πŸ”₯Modify a line of code in train.py, easily switch to any framework!

import os
os.environ['TL_BACKEND'] = 'tensorflow'
# os.environ['TL_BACKEND'] = 'mindspore'
# os.environ['TL_BACKEND'] = 'paddle'

🚧 We will support PyTorch as Backend soon.

Evaluation.

πŸ”₯ We have trained SRGAN on DIV2K dataset. πŸ”₯ Download model weights as follows.

SRGAN_g SRGAN_d
TensorFlow Baidu, Googledrive Baidu, Googledrive
PaddlePaddle Baidu, Googledrive Baidu, Googledrive
MindSpore 🚧Coming soon! 🚧Coming soon!
PyTorch 🚧Coming soon! 🚧Coming soon!

Download weights file and put weights under the folder srgan/models/.

Your directory structure should look like this:

srgan/
    └── config.py
    └── srgan.py
    └── train.py
    └── vgg.py
    └── model
          └── vgg19.npy
    └── DIV2K
          β”œβ”€β”€ DIV2K_train_HR
          β”œβ”€β”€ DIV2K_train_LR_bicubic
          β”œβ”€β”€ DIV2K_valid_HR
          └── DIV2K_valid_LR_bicubic
    └── models
          β”œβ”€β”€ g.npz  # You should rename the weigths file. 
          └── d.npz  # If you set os.environ['TL_BACKEND'] = 'tensorflow',you should rename srgan-g-tensorflow.npz to g.npz .

  • Start evaluation.
python train.py --mode=eval

Results will be saved under the folder srgan/samples/.

Results

Reference

Citation

If you find this project useful, we would be grateful if you cite the TensorLayer paper:

@article{tensorlayer2017,
author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
journal = {ACM Multimedia},
title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
url = {http://tensorlayer.org},
year = {2017}
}

@inproceedings{tensorlayer2021,
  title={TensorLayer 3.0: A Deep Learning Library Compatible With Multiple Backends},
  author={Lai, Cheng and Han, Jiarong and Dong, Hao},
  booktitle={2021 IEEE International Conference on Multimedia \& Expo Workshops (ICMEW)},
  pages={1--3},
  year={2021},
  organization={IEEE}
}

Other Projects

Discussion

License

  • For academic and non-commercial use only.
  • For commercial use, please contact [email protected].

srgan's People

Contributors

zsdonghao avatar hanjr92 avatar akaraspt avatar chriswu1997 avatar laicheng0830 avatar luomai avatar saren-arterius 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.