codeslake / DMENet

[CVPR 2019] Official TensorFlow Implementation for "Deep Defocus Map Estimation using Domain Adaptation"
GNU Affero General Public License v3.0
122 stars 24 forks source link

Output of DMENet #10

Closed chanwental closed 4 years ago

chanwental commented 4 years ago

Hi,Dr.Lee.

When I test the network,I get the file named as _xxxx_2_defocus_mapout.png.

I want to know what value is saved in this file .

Thank you and look forward to your reply!

Best, Cheng

codeslake commented 4 years ago

It contains the value of sigma, if you test our model with the model checkpoint that we shared. (We have retrained the model with SYNDOF dataset containing sigma value. When we read the dataset, we did not divide it by 15.)

If you train the model with SYNDOF that we shared, xxxx_2_defocus_map_out.png. will contain max-normalized max_coc. If you want to get sigma, you have to do ((network_ouput*15) - 1)/2 during training and testing.

Sorry for the confusion.

chanwental commented 4 years ago

I am still confused.

The file named as xxxx_2_defocus_map_out.png is generated when I test the model with the model checkpoint that you shared. 1)The input is synthetic image generateed by your SYNDOF code (max_coc=29). So the corresponding blur_map is known and the max_sigma is known (max_sigma=7). But the range of value in _xxxx_2_defocus_mapout.png is not around [0, 7]. 2)The blur_map is not visible. That's reasonable because It contains the value of sigma(*10). However, the xxxx_2_defocus_map_out.png is visible. The values saved in it don't seem to be sigma.

I read a _xxxx_2_defocus_mapout.png as follows:

_file_name = 'logs/DMENet_BDCS/samples/1_test/2020_10_29/19-29/out/0000.png' image = ((cv2.imread(file_name, cv2.IMREADUNCHANGED)))

codeslake commented 4 years ago

I apologize again for the confusion.

My previous answer was wrong.

  1. We have not retrained the network SYNDOF containing sigma value.

  2. If you are using the model and checkpoint that I shared for testing an image, the value of _xxxx_2_defocus_mapout.png contains "max-normalized" CoC. If you want to get actual sigma value, you will have to do.

_sigma = ((defocusmap * 15) - 1) / 2.

chanwental commented 4 years ago

I found that the maximum of values in a defocus_map is around 200. And every defocus_map has different one. It doesn't seem to be the value normalized.

If _max_defocusmap =200, _maxsigma is 1499.5.

codeslake commented 4 years ago

I don't get it. The range of defocus_map should between 0 and 1 as the final layer of the network is sigmoid.

Try this.

_defocus_map = ((cv2.imread(file_name, cv2.IMREAD_UNCHANGED))) / 255. sigma = ((defocusmap * 15) - 1) / 2.

chanwental commented 4 years ago

Thank you. I get it.