Git Product home page Git Product logo

srntt-pytorch's Introduction

srntt-pytorch

A PyTorch implementation of SRNTT[1], which is a novel Reference-based Super-Resolution method proposed in CVPR 2019.

Requirements

Python

$ python --version
Python 3.7.4

Packages

Mainly used packages are below:

- torch
- torchvision
- kornia
- scikit-learn etc., see more in Pipfile

This Python environment is managed by pipenv, so you can create a virtual environmet like below:

$ pipenv install

[WIP] Working with Docker ๐Ÿณ

Build Docker image

$ sudo docker build -t srntt-pytorch .

Run Docker container

$ sudo docker run --rm --runtime nvidia -it srntt-pytorch /bin/bash

Training

Get started

$ sh scripts/train.sh

More detailed descriptions are provided in the following sections.

Downloading data

You can get data through the following command, which is provided by the author.

$ python download_dataset.py --dataset_name DATASE_NAME

The available dataset names are {DIV2K, CUFED, CUFED5}. DIV2K and CUFED datasets can be used as train data, and CUFED5 can be used as test data. The downloaded data will be placed in ./data directory.

Downloading a pre-trained weight

In the training of SRNTT, the initial weights for content extractor is set as pre-trained SRGAN model. In this implementation, we exploit Modified-SRGAN (MSRGAN) provided by MMSR bacause it is thought as a reliable source. Let's download it as below!

$ python download_pretrained_model.py

Offline texture swapping

SRNTT requires HR-LR image pairs and the corresponding reference(Ref) images, moreover the swapped feature maps culculated from LR-Ref images. The calculation is time-comsuming and has high comtational costs.

In general, the swapped feature maps of train data is culculated offline to speed up the training. The offline calculation will be done by the following command.

$ python offline_texture_swapping.py --dataroot DATSET_NAME

Training SRNTT

All of the preparation was done as above, so let's train the networks. We recommend to use --use_weights option at all times (appeared in Eq. (6)).

$ python train.py --use_weights

Testing

You can test on CUFED5 dataset as below. If you have not used --use_weights option in the training, you don't have to specify the option.

$ python test.py -w ./runs/your/pth/path --use_weights

Online inference on any images

Now, we support online inference on any images. The input image you specify will be x4 downscaled by bicubic, and super-resolved with your ref image.

$ python online_inference.py -w ./runs/your/pth/path -i ./your/input/image -r ./your/ref/image --use_weights

Pretrained models

You can get pretrained models from here.

Results

HR/LR image means GT/input image. MSRGAN is the result of MSRGAN from MMSR. SR image (HR) indicates super-resolved image with HR image itself, and SR image (Lx) indicates super-resolved one with a similar reference (left bottom) image. comparison_002 comparison_065 comparison_078

See the other results and metrics here.

Reference

Thanks you for the following!

Papers

  1. Zhang, Zhifei, et al. "Image Super-Resolution by Neural Texture Transfer." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2019.

Implementations

  1. The original implementation (TF) - https://github.com/ZZUTK/SRNTT
  2. MMSR - https://github.com/open-mmlab/mmsr

srntt-pytorch's People

Contributors

s-aiueo32 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.