amitshaked / resmatch

Implementation of "Improved Stereo Matching with Constant Highway Networks and Reflective Confidence Learning"
BSD 2-Clause "Simplified" License
75 stars 27 forks source link

How can I generate the disparity map of some stereo pair? #13

Open LUCASLLA opened 6 years ago

LUCASLLA commented 6 years ago

Hi, I want to see the disparity map of some test cases, but there's nothing about it on the Readme file. Anyone knows how to generate them? Tks.

HyuanTan commented 6 years ago

@LUCASLLA Hi, you can make a directory under src named tmp, and set the -save_img option in main.lua to true and fix some bug in function save_png of script runner.lua(such as there is not network.name in that script, you need to delete something relative with it). After all above, run th main.lua -ds kitti -a test -gpu 1 -mc resmatch -m fast, then you can see some predict image under the ./src/tmp folder.

LUCASLLA commented 6 years ago

Hi @HyuanTan , thank you for your response, however, I'm having a memory error when I try to execute this line:

$ th main.lua -ds kitti -a test -gpu 1 -mc resmatch -m fast ===> Loading matching cost network...
===> Loaded! Network: kitti_resmatch_fast_LL_rgb
THCudaCheck FAIL file=/home/myuser/torch/extra/cutorch/lib/THC/generic/THCStorage.cu line=66 error=2 : out of memory /home/myuser/torch/install/bin/luajit: ./networks/network.lua:158: cuda runtime error (2) : out of memory at /home/myuser/torch/extra/cutorch/lib/THC/generic/THCStorage.cu:66 stack traceback: [C]: in function 'clone' ./networks/network.lua:158: in function 'forwardFree' ./networks/network.lua:153: in function 'forwardFree' ./networks/network.lua:153: in function 'forwardFree' ./networks/mc-models/matching.lua:49: in function 'getDescriptors' ./networks/mc-models/fast.lua:20: in function 'match' ./runner.lua:29: in function 'predict' ./runner.lua:67: in function 'test' main.lua:168: in main chunk [C]: in function 'dofile' ...myuser/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:150: in main chunk [C]: at 0x00405d50

Do you know how much gpu memory is necessary to run this script, or maybe if there's a way to avoid this error? I can really see my gpu memory (2 GB) going away very fast when I run this line. Tks.

HyuanTan commented 6 years ago

@LUCASLLA Hi, I run th main.lua -ds kitti -a test -m fast -mc resmatch -mcnet ../pretrained/kitti2012_resmatch_fast/mc/kitti_resmatch_fast_LL_rgb_all_net.t7 -dispnet ../pretrained/kitti2012_resmatch_fast/disparity/net_reflective_kitti_resmatch_fast_LL_rgb_all_net.t7 -gpu 1 for inference and it took about 5 GB gpu memory on my machine.

amitshaked commented 6 years ago

@HyuanTan thank you so much for the help! @LUCASLLA you can try to lower the image resolution or to run the prediction on a different part of the image every time (with some overlap between the parts). It's not implemented but a pull request is more than welcomed :)

wujunjie15 commented 6 years ago

@LUCASLLA Hi, have you discovered how to test some pictures? Can you tell me details? Thanks!

gcaffaratti commented 6 years ago

Another way to reduce the memory consumption is disabling torch's cache. This can be done by adding/changing the environment variable THC_CACHING_ALLOCATOR to 0:

export THC_CACHING_ALLOCATOR = 0

This makes Torch run a little slow but reduces the memory consumption a lot.