haofeixu / aanet

[CVPR'20] AANet: Adaptive Aggregation Network for Efficient Stereo Matching
Apache License 2.0
521 stars 100 forks source link

Run in Google colab #75

Closed Jack47746 closed 1 year ago

Jack47746 commented 2 years ago

Has anyone run it on google colab? The installation environment keeps failing. image Running build. sh file image

egorchistov commented 2 years ago

I managed to run AANet+ prediction on Google Colab

Here is a working example. First you need to make sure that your instance has a GPU

import torch

assert torch.cuda.is_available()

Then run

%%shell
git clone https://github.com/haofeixu/aanet.git
cd aanet
mkdir -p pretrained
gdown --id 1m0z8e2Ndau_eFR3BETffzjkNXhJNHAiS --output pretrained/aanet+_kitti15-2075aea1.pth

pip install ninja  # Optional

cd nets/deform_conv

# https://github.com/pytorch/pytorch/issues/28472#issuecomment-545425721
sed -i -- 's/AT_CHECK/TORCH_CHECK/g' src/deform_conv_cuda.cpp
sed -i -- 's/.data</.data_ptr</g' src/deform_conv_cuda_kernel.cu

sh build.sh

cd ../..
sh scripts/aanet+_predict.sh
finnick99 commented 2 years ago

I managed to run AANet+ prediction on Google Colab

* The main thing is NOT to use environment.yml, as it breaks something in the Google Colab environment

* In addition, you need to patch the deform_conv code

Here is a working example. First you need to make sure that your instance has a GPU

import torch

assert torch.cuda.is_available()

Then run

%%shell
git clone https://github.com/haofeixu/aanet.git
cd aanet
mkdir -p pretrained
gdown --id 1m0z8e2Ndau_eFR3BETffzjkNXhJNHAiS --output pretrained/aanet+_kitti15-2075aea1.pth

pip install ninja  # Optional

cd nets/deform_conv

# https://github.com/pytorch/pytorch/issues/28472#issuecomment-545425721
sed -i -- 's/AT_CHECK/TORCH_CHECK/g' src/deform_conv_cuda.cpp
sed -i -- 's/.data</.data_ptr</g' src/deform_conv_cuda_kernel.cu

sh build.sh

cd ../..
sh scripts/aanet+_predict.sh

When I use ‘’%%shell bash aanet+_predict.sh‘’ in colab appear problem ‘’python3: can't open file 'predict.py': [Errno 2] No such file or directory‘’ how can solve look forward to your reply

egorchistov commented 2 years ago

I assumed that all the code would be inserted into one cell with %%shell magick to preserve the working directory inside the cell. Have you done so? Apparently you are running the script from the wrong folder. You should cd in the aanet/ folder.

haofeixu commented 1 year ago

Hi all, sorry for the late response.

If this issue is still relavant to you, I would suggest to try our new GMStereo model: https://haofeixu.github.io/unimatch/ & https://github.com/autonomousvision/unimatch. No CUDA op is required. A Colab demo is also provided to try our model in your browser. Hope it helps, thanks.