Git Product home page Git Product logo

pytorch-learning-to-see-in-the-dark's Introduction

pytorch-Learning-to-See-in-the-Dark

Learning to See in the Dark using PyTorch 0.4.0 and 1.0.0

Original tensorflow version

Chen Chen, Qifeng Chen, Jia Xu, and Vladlen Koltun, "Learning to See in the Dark", in CVPR, 2018.
Tensorflow code
Paper

Requirements

  • 64 GB RAM
  • GTX 1080
  • PyTorch >= 0.4.0 (1.0.0 and 1.6.0 are also tested)
  • RawPy >= 0.10 (0.15 is also tested)

The program have been tested on Ubuntu 18.04, 16.04, and Windows 10.

Download Dataset

Download the dataset following the instruction in the original code and unzip it under the directory dataset.

pytorch-Learning-to-See-in-the-Dark
  ├── dataset
  │   ├── image-here
  │   ├── Sony
  │   │   ├── long
  |   │   ├── short
  .   .   .

Training

python train_Sony.py

  • It will save model and generate result images every 100 epochs.
  • The trained models will be saved in saved_model/ and the result images will be saved in result_Sony/.
  • The result of the current output is displayed on the right side of the image file with the ground truth counter part shown on the left side.

Testing

Download trained model

You can download the trained pytorch model here and put it in folder saved_model/.

python test_Sony.py

  • The trained model is only for .ARW photos taken by Sony cameras.
  • Pytorch somehow needs more GPU resources than Tensorflow. Therefore, it is impossible to take in the whole image.
  • Testing will only take 1024 * 1024 pixels from the test images.
  • This testing script is only for checking the performance of the trained model.
  • The result will be saved in test_result_Sony with gt as ground truth images, scale as scaled images, ori as input images, and out as output images.

Todo

I have tried to feed the sliced input images into the model and put the result back to the original size. But there still remains two problems:

  1. The edges of the sliced input images are quite obvious in the recovered result images.
  2. There is no padding SAME in pytorch. Hence, images with incompetible shape might result in errors. failure case

License

MIT License.

Please contact me you have any questions. [email protected]

pytorch-learning-to-see-in-the-dark's People

Contributors

lavi135246 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

pytorch-learning-to-see-in-the-dark's Issues

Training time?

Hey, how much time it approximately takes to train the SONY model using the specified configuration?

scale_full

How to understand origin_full = scale_full?Why are the results very different?
How to understand scale_full = scale_full*np.mean(gt_full)/np.mean(scale_full)?
What is the role of scale_full?

Cant make it work on Cuda [windows]

Hi

CPU works, but cuda shows error. I cant figure out how to fix it.
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

Thanks

Maybe There is a bug in train.py, when flip the image

Here in the second if, I think the axis should be 2. axis=0 means flip along the batch dimension

    if np.random.randint(2,size=1)[0] == 1:  # random flip 
        input_patch = np.flip(input_patch, axis=1)
        gt_patch = np.flip(gt_patch, axis=1)
    if np.random.randint(2,size=1)[0] == 1: 
        input_patch = np.flip(input_patch, **axis=0**)
        gt_patch = np.flip(gt_patch, **axis=0**)
    if np.random.randint(2,size=1)[0] == 1:  # random transpose 
        input_patch = np.transpose(input_patch, (0,2,1,3))
        gt_patch = np.transpose(gt_patch, (0,2,1,3))

im = raw.postprocess

How to understand im = raw.postprocess(use_camera_wb=True, half_size=False, no_auto_bright=True, output_bps=16)

About the codes

Thanks for releasing the code. I want to know if you have got the results of the paper when using the pytorch codes.

Where is the slice operation in test code?

Hello,
You mentioned that you slice the original input images into small pieces(1024*1024) in readme, however, I cannot find the corresponding operations in the test code. Would you please tell me where is the slice operation? thank you~

Test

when you test,you can use torch.nograd().

Considering your failure case

I'm pretty sure you can just pass the whole image into the network for testing, so you wouldn't need to slice it up.

Does the function _initialize_weights() necessary?

You have added a _initialize_weights() function, does it is necessary to pytorch?

def _initialize_weights(self): for m in self.modules(): if isinstance(m, nn.Conv2d): m.weight.data.normal_(0.0, 0.02) if m.bias is not None: m.bias.data.normal_(0.0, 0.02) if isinstance(m, nn.ConvTranspose2d): m.weight.data.normal_(0.0, 0.02)

cuda memory insufficient

Hi, thanks for your work!
I am trying test.py on gpu, but got error "cuda out of memory".(rtx 2080ti)
Any solution could solve this?
thanks!

about the loss function

I want to use pytorch to implement a new loss function. And almost all the online information say that I should make a new class that inherit the nn.Module. But I found you just create a function ‘reduce_mean()’. Does it means that it is just so easy in pytorch to make an own funtion.

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.