Giter Club home page Giter Club logo

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

Learning-to-See-in-the-Dark

This is a Tensorflow implementation of Learning to See in the Dark in CVPR 2018, by Chen Chen, Qifeng Chen, Jia Xu, and Vladlen Koltun.

Project Website
Paper

teaser

This code includes the default model for training and testing on the See-in-the-Dark (SID) dataset.

Demo Video

https://youtu.be/qWKUFK7MWvg

Setup

Requirement

Required python (version 2.7) libraries: Tensorflow (>=1.1) + Scipy + Numpy + Rawpy.

Tested in Ubuntu + Intel i7 CPU + Nvidia Titan X (Pascal) with Cuda (>=8.0) and CuDNN (>=5.0). CPU mode should also work with minor changes but not tested.

Dataset

Update Aug, 2018: We found some misalignment with the ground-truth for image 10034, 10045, 10172. Please remove those images for quantitative results, but they still can be used for qualitative evaluations.

You can download it directly from Google drive for the Sony (25 GB) and Fuji (52 GB) sets.

There is download limit by Google drive in a fixed period of time. If you cannot download because of this, try these links: Sony (25 GB) and Fuji (52 GB).

New: we provide file parts in Baidu Drive now. After you download all the parts, you can combine them together by running: "cat SonyPart* > Sony.zip" and "cat FujiPart* > Fuji.zip".

The file lists are provided. In each row, there are a short-exposed image path, the corresponding long-exposed image path, camera ISO and F number. Note that multiple short-exposed images may correspond to the same long-exposed image.

The file name contains the image information. For example, in "10019_00_0.033s.RAF", the first digit "1" means it is from the test set ("0" for training set and "2" for validation set); "0019" is the image ID; the following "00" is the number in the sequence/burst; "0.033s" is the exposure time 1/30 seconds.

Testing

  1. Clone this repository.
  2. Download the pretrained models by running
python download_models.py
  1. Run "python test_Sony.py". This will generate results on the Sony test set.
  2. Run "python test_Fuji.py". This will generate results on the Fuji test set.

By default, the code takes the data in the "./dataset/Sony/" folder and "./dataset/Fuji/". If you save the dataset in other folders, please change the "input_dir" and "gt_dir" at the beginning of the code.

Training new models

  1. To train the Sony model, run "python train_Sony.py". The result and model will be save in "result_Sony" folder by default.
  2. To train the Fuji model, run "python train_Fuji.py". The result and model will be save in "result_Fuji" folder by default.

By default, the code takes the data in the "./dataset/Sony/" folder and "./dataset/Fuji/". If you save the dataset in other folders, please change the "input_dir" and "gt_dir" at the beginning of the code.

Loading the raw data and processing by Rawpy takes significant more time than the backpropagation. By default, the code will load all the groundtruth data processed by Rawpy into memory without 8-bit or 16-bit quantization. This requires at least 64 GB RAM for training the Sony model and 128 GB RAM for the Fuji model. If you need to train it on a machine with less RAM, you may need to revise the code and use the groundtruth data on the disk. We provide the 16-bit groundtruth images processed by Rawpy: Sony (12 GB) and Fuji (22 GB).

Citation

If you use our code and dataset for research, please cite our paper:

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

License

MIT License.

FAQ

  1. Can I test my own data using the provided model?

The proposed method is designed for sensor raw data. The pretrained model probably not work for data from another camera sensor. We do not have support for other camera data. It also does not work for images after camera ISP, i.e., the JPG or PNG data.

  1. Will this be in any product?

This is a research project and a prototype to prove a concept.

  1. How can I train the model using my own raw data?

Generally, you just need to subtract the right black level and pack the data in the same way of Sony/Fuji data. If using rawpy, you need to read the black level instead of using 512 in the provided code. The data range may also differ if it is not 14 bits. You need to normalize it to [0,1] for the network input.

  1. Why the results are all black?

It is often because the pre-trained model not downloaded properly. After downloading, you should get 4 checkpoint related files for the model.

Questions

If you have additional questions after reading the FAQ, please email to [email protected].

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

Contributors

cchen156 avatar imkuang avatar jason-cooke avatar kkruups avatar prabodhw96 avatar timgates42 avatar woj-i 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  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

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

About rgb training

paper has sRGB input comparision, I modify the last two level conv10(12 channel ) to output 3channel for the rgb input image generated by rawpy.
the training loss is down to 0.025, the result is not bad, but some image is not real. is this correct way?

Why psnr values differ so much when input Sony and Fuji rgb datasets

It's hard to ignore that in your paper Table 3, the psnr of Sony rgb input is 17.4 while another psnr is 25.11. I couldn't understand why they differ so much when both are rgb images. I mean,if input rgb images, they must have gone through the same process before put into the network.
And would you mind to explain how you convert your raw datasets to rgb images, and how to understand this difference?

misalignment problem in the dataset

A question in the test_Sony.py is that, the scipy.io is really slow and cv2.imwrite is really fast. In the 8-bit saving way, do this two methods inference the finnaly PSNR & SSIM?

error in test_Sony.py

after download and extract raw Sony data in dir dataset/Sony.
run test_Sony.py
got error at line 151:
im = raw.postprocess(use_camera_wb=True, half_size=False, no_auto_bright=True, output_bps=16)

rawpy._rawpy.LibRawFatalError: b'Unsufficient memory'
could you have met this?
Appreciate for answer.

16bit bayer filter

  1. Can I use a Sony network model for a 16bit bayer filter?
  2. Is it possible to share iphone 6s raw images(dng format) in paper?

Questions regarding to the PSNR/SSIM results

Hi @cchen156 ,

This work is very exciting. But I have a question about the quantitative results reported in the paper Table3.

I downloaded the source code and trained model, and tested Sony dataset. I generate GT by Rawpy and apply Gamma transfer after it, since you apply Gamma transfer on the output of the network in your test code. I found that the results looks fine, but the average PSNR/SSIM in the testset is 25.44/0.713, which is quite lower than 28.88/0.787 reported in Table3 in your paper.

If I have made some mistake? How can I get the reported results.

Thanks,
Wenbo

Trained model (for iPhone)

Amazing results, congrats!

Is it possible to download from somewhere the pre-trained model?

Thanks a lot!

TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

What`s this probably mean?Here is the log:

Traceback (most recent call last):
File "test_Sony.py", line 117, in
out_image = network(in_image)
File "test_Sony.py", line 76, in network
up6 = upsample_and_concat(conv5, conv4, 256, 512)
File "test_Sony.py", line 50, in upsample_and_concat
deconv_output = tf.concat([deconv, x2], 3)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1075, in concat
dtype=dtypes.int32).get_shape(
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 165, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).name))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

train_Sony.py refer to the wrong dir

I think that train_Sony.py at line 129

allfolders = glob.glob('./result/*0')

and train_Sony.py at line 136

if os.path.isdir("result/%04d" % epoch):

are wrong.

The correct programs are

allfolders = glob.glob(result_dir + '*0')
if os.path.isdir(result_dir + "%04d" % epoch):

, right?

Pnsr and SSIM

Hello,@cchen156,I used the cpkt file you provided to test PNSR and SSIM, but the measured value is still lower than the original text, PNSR=28.639, SSIM=0.7682, is it different from the method I used to test pnsr and ssim? Can you provide the method or code for testing pnsr and ssim?

The comparison with HDRnet

Hi,
Thanks for sharing this work and the result is awesome ! @cchen156
I find comparison with hdrnet in the project page , so are you using HDRnet prettrained model from @mgharbi 's repo or you trained the comparison model youself?

I want to reproduce the comparison but seems no night related pretrained model is found for hdrnet, would you like to share the comparison pretrained model ? Thanks

Why the batch_size is 1?

I don't understand why you set the batch_size=1, i.e., only 1 picture will be trained in one iteration. Have you ever tried other batch_sizes?

comparison between output of SID(see in the dark) and photoshop

I tried to compare the output generated by SID (O-sid) and photoshop (O-ps, with all auto from DNG to PNG), and according to what I saw:
1/ when the light is extremely low, O-sid is better than O-ps.
2/ but when the light is low and not extremely, O-ps is better than O-sid.

Also, O-sid loses quite a few texture compared to O-ps.
I wonder is this as expected?

Result of sony

I downloaded the sony data of 22 GB, the training and testing programs were executed, the folder named 'result_sony' is created, with some files in it, but those files are not executable and there were no images to be seen, can you please tell me that was result was expected once the program is executed completely.

Python 3 support

I noticed that the README suggests it needs Python 2.7 but from looking at the libraries, nothing jumps out that would be dependent on 2.7, so I'd have expected it to run with 3.

Is it simply that 2.7 is what you happened to develop / test with, or is there something in your code that specifically needs 2.7?

freeze model

Can you get the inference freeze.pb file for your model?
what is your input node name ? output node name?

Any hint for running on other camera raw (nikon,canon)

Hi!
I was able to run the examples for Sony raw data and the results are amazing.
I would like to experiment with Canon and Nikon raws but with Canon's raws the model seems to never converge. I am able to run it but i don't get any output. I modified the test_Sony file changing the ARW extension in CR2 (Canon's raw). Any advice?

Thank you!

ratio multiplication

@kkruups @prabodhw96 @cchen156 Hi, congrats for your work. In your paper and code, during training, input and corresponding ground truth are first scaled between [0-1], and then input are scaled by ratio but the ground truth is still between [0-1]. Have you tried not to scale input by ratio and keep input and gt both in range [0-1] to train the network? Will it get better result and what's your opinion? THX!

apply whitebalance before feed into network

@cchen156 Hi, congrats first. In your training settings now, you aim to learn white balance within the network. Have you tried to apply white balance on input(those short exposure images) before feeding them into networks? If so, how does the result look like? THX!

Could you provide training test data set within 2G.

Hello,thank you for your help.Because my computer configuration is too low, RAM is only 4G, gpu memory 2G, although you provide sonny(12G) data set, but still a bit big for me and I can't download it .so could you provide training test data set within 2G. I just want to use a small amount of data to test the model.
Thank you !

The gpu memory is occupied when I run the train_Sony.py

The gpu memory is occupied when I run the train_Sony.py, so I set

tfconfig = tf.ConfigProto(allow_soft_placement=True) tfconfig.gpu_options.allow_growth=True sess = tf.Session(config=tfconfig)

But there is still the question...?

About PSNR

Hi @cchen156 i test psnr of ur model on test samples 1-49 in ur test_list.txt , and the psnr is ~32dB ,is that the same with urs ? i didnt change any of ur codes
My PSNR Calculation :
PSNR(img1,img2):
mse = np.mean((img1 - img2)^2)
return 10*np.log10(255^2 / mse);

can't download data

why can not i download the data?
The website always return:
Bad Request
Error 400

How about training with 8-bit jpg image?

I just tried to train Sony dataset after converting the raw data into jpg image and found the result quite terrible. So are there any tricks when training 8bit data?
P.S.:
The channel number of input is 12, which results from packing each channel of rgb into four.

The quantization

Hi,

Thanks for your novel work. I have some questions. I noticed that you restrict the value of ground truth image around 0 to 1, then force the model to generate output image which is also around 0 to 1. I am confused that why not just use the original ground truth image as the label and produce the output image directly without multiplying 255. Is there any difference between these two ways? Could you please help answer this question?

Thanks,

how to export the raw data of iphone?

GREAT WORK!

There's a certain app you mentioned in your paper, which can set parameters and export raw data.
Could you please tell me what's the name of the app?

I only know we can access YUV data through Apple's API.

Thanks~!

[Enhancement] Add input image to the result

Hi, thanks for your great work.
This issue is just a suggestion of possible enhancement.
When testing the model, currently the output images are ground truth, the output from the neural network, and the input scaled up to the same mean as ground truth.

My suggestion is to add

scipy.misc.toimage(input_full[0,:,:,:]*255,  high=255, low=0, cmin=0, cmax=255).save(result_dir + 'final/%5d_00_%d_in.png'%(test_id,ratio))

to output the initial input image, to show how unusable the original photo is.

Training time

How long did the training on Titan X take? What was the final loss?

Pedestrian detection in low light

Hi, I am work on the project which can detect and track pedestrian in low light or night. Then how can I use your model for my dataset?

Any script for downloading Sony 12GB?

Hi Chen,

Thanks for your code, it is very useful!

I just wonder could you please provide the script for downloading Sony 12GB? It will help me a lot!

Thanks,

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.