mrharicot / monodepth

Unsupervised single image depth prediction with CNNs
Other
2.22k stars 631 forks source link

divide by zero error #169

Closed ehabhelmy82 closed 6 years ago

ehabhelmy82 commented 6 years ago

Dear Author Many times I got divide by zero when I try to modify your code even simple modification like changing Alpha value for appearance loss term could result in this error during evaluation. Do you have any idea why and what does it mean and how to fix it? Thanks

Hint This the error message i got /data/ehab/data_scene_flow/training/disp_noc_0/000189_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000190_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000191_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000192_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000193_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000194_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000195_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000196_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000197_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000198_10.png /data/ehab/data_scene_flow/training/disp_noc_0/000199_10.png /data/ehab/monodepth-master/utils/evaluation_utils.py:61: RuntimeWarning: divide by zero encountered in divide pred_depth = width_to_focal[width] * 0.54 / pred_disp abs_rel, sq_rel, rms, log_rms, d1_all, a1, a2, a3 6.0278, 418.4342, 64.898, 1.888, 100.000, 0.009, 0.027, 0.057

mrharicot commented 6 years ago

Hi, Did you try visualising the depth maps? It is very likely that the network fails to train and outputs zeros everywhere as disparity, which triggers the divide by zero error. In case this is an isolated zero in the disparities you can "fix" it by adding a small epsilon: pred_depth = width_to_focal[width] * 0.54 / (pred_disp + 1e-5)

ehabhelmy82 commented 6 years ago

I tried it but still the same result What could be the reason for the network failure to train? one more question, What is the max_val: The dynamic range of the images that is being used for appearance loss calculation is it 1 or 255?

mrharicot commented 6 years ago

It is hard to guess without knowing what modifications you did. It is always safe to try and train with a lower learning rate if this happens. You should always monitor training and look at the predicted depthmaps and the loss.

The dynamic range is [0, 1].