Giter VIP home page Giter VIP logo

pytorch-zssr's Introduction

Unofficial PyTorch implementation of "Zero-Shot" Super-Resolution using Deep Internal Learning

Unofficial Implementation of 1712.06087 "Zero-Shot" Super-Resolution using Deep Internal Learning by Assaf Shocher, Nadav Cohen, Michal Irani.

Official Project page: http://www.wisdom.weizmann.ac.il/~vision/zssr/

Paper: https://arxiv.org/abs/1712.06087


This trains a deep neural network to perform super resolution using a single image.

The network is not trained on additional images, and only uses information from within the target image. Pairs of high resolution and low resolution patches are sampled from the image, and the network fits their difference.

Low resolution ZSSR

ZSSR ZSSR


TODO:

  • Implement additional augmentation using the "Geometric self ensemble" mentioned in the paper.
  • Implement gradual increase of the super resolution factor as described in the paper.
  • Support for arbitrary kernel estimation and sampling with arbitrary kernels. The current implementation interpolates the images bicubic interpolation.

Deviations from paper:

  • Instead of fitting the loss and analyzing it's standard deviation, the network is trained for a constant number of batches. The learning rate shrinks x10 every 10,000 iterations.

Usage

Example: python train.py --img img.png

usage: train.py [-h] [--num_batches NUM_BATCHES] [--crop CROP] [--lr LR]
                [--factor FACTOR] [--img IMG]

optional arguments:
  -h, --help            show this help message and exit
  --num_batches NUM_BATCHES
                        Number of batches to run
  --crop CROP           Random crop size
  --lr LR               Base learning rate for Adam
  --factor FACTOR       Interpolation factor.
  --img IMG             Path to input img

pytorch-zssr's People

Contributors

jacobgil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytorch-zssr's Issues

IndexError: too many indices for array on line 46 in train, cpu_loss = error.data.cpu().numpy()[0]

(base) C:\Users\Luke Chen\Desktop\pytorch-zssr-master>python train.py --crop 30 --num_batches 8 --img img.png
train.py:18: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
  init.kaiming_normal(m.weight.data, a=0, mode='fan_in')
  0%|                                                                                            | 0/8 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "train.py", line 118, in <module>
    train(model, img, args.factor, args.num_batches, args.lr, args.crop)
  File "train.py", line 46, in train
    cpu_loss = error.data.cpu().numpy()[0]
IndexError: too many indices for array

FileNotFoundError: [Errno 2] No such file or directory: 'lincoln.png'

(torch14) C:\Users\15479\Desktop\pytorch-zssr-master>python train.py --img lincoln.png
Traceback (most recent call last):
File "train.py", line 105, in
img = PIL.Image.open(args.img)
File "E:\anaconda\envs\torch14\lib\site-packages\PIL\Image.py", line 2891, in open
fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: 'lincoln.png'

I'm a green hand.Please tell me What should be after --img?
How to set?
Please ,help me bro!!!

compare with the original txt

I use the defalut parameters.
lr = 1e--5
nums = 15000
in fact, I test in Set14,and get the results as:
x2,psnr:29.75,ssim:0.88
however, the original txt is:
x2,psnr:33.00,ssim:0.9108.
I want to know ,did you test in Set14,and what's your results.

Kernel estimation?

I was wondering if you had a chance to look into the kernel estimation part of the paper, as that is what really lets ZSSR be more useful than other SR methods (per the paper). If not, do you have any guidance for trying to implement it? In particular, how can image resizing with an arbitrary kernel be done?

CUDA out of memory.

I ran everything with default settings just to test the code ( run train.py --img lincoln.png).
I got the 2x enlarged image.

Then I used this 2x image as input to magnify it to 4x. During this run, all the 15000 epochs were completed and a new image file called 'low_res.png' was found in the folder. But after this, the program stopped without completion with the following message :

CUDA out of memory. Tried to allocate 788.00 MiB (GPU 0; 4.00 GiB total capacity; 2.38 GiB already allocated; 531.39 MiB free; 128.68 MiB cached)

Also, during the running of the program, I checked the task manager and it was always like CPU(near 100%), GPU(2%).

Can someone help me understand the issue and help me find a solution?

Poor inference result

I set "lincoln.png" in the example folder as input and run the code. It turns out that the result is hardly different from the input LR. I took a brief look at the code but nothing seems wrong. I wonder if you had the same problem.

问题交流

请问你最近还在做这个项目吗?如果看到的话,可以加下qq什么的。有一些问题想请教一下

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.