aim-uofa / AdelaiDepth

This repo contains the projects: 'Virtual Normal', 'DiverseDepth', and '3D Scene Shape'. They aim to solve the monocular depth estimation, 3D scene reconstruction from single image problems.
Creative Commons Zero v1.0 Universal
1.06k stars 144 forks source link

LeReS in Anaconda on Window - ModuleNotFoundError: No module named 'lib' #61

Closed vitacon closed 1 year ago

vitacon commented 1 year ago

I'm trying to run LeReS in Anaconda on Windows 10. I had no problem during preinstallation (env, install pytorch etc., pip) but I can't run test_depth.py.

export PYTHONPATH="c:\Users\Vita\video\adelai-leres\LeReS\Minist_Test"

'export' is not recognized as an internal or external command,
operable program or batch file.

I guess I need to replace Export by Set in Windows. set PYTHONPATH="c:\Users\Vita\video\adelai-leres\LeReS\Minist_Test"

So I run python Minist_Test\tools\test_depth.py --load_ckpt res50.pth --backbone resnet50

Traceback (most recent call last):
  File "Minist_Test\tools\test_depth.py", line 9, in <module>
    from lib.multi_depth_model_woauxi import RelDepthModel
ModuleNotFoundError: No module named 'lib'

The file seems to be in the right place: c:\Users\Vita\video\adelai-leres\LeReS\Minist_Test\lib\multi_depth_model_woauxi.py

I suppose the problem should be fixed by setting the temporary path to Minist_Test\lib but I can't figure out how... =(

vitacon commented 1 year ago

Whew... I made it work.

I had to print sys.path to find out what's going on.

set PYTHONPATH=

C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test\tools
C:\Users\Vita\Anaconda3\envs\LeReS\python37.zip
etc.

set PYTHONPATH="C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test"

C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test\tools
C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test\"C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test"
C:\Users\Vita\Anaconda3\envs\LeReS\python37.zip
etc.

OMG!

set PYTHONPATH=.

C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test\tools
C:\Users\Vita\video\adelai-leres\LeReS\Minist_Test
C:\Users\Vita\Anaconda3\envs\LeReS\python37.zip
etc.

This looked promising but it was not enough:

loading checkpoint res50.pth
Traceback (most recent call last):
  File "tools\test_depth.py", line 65, in <module>
    imgs_list = os.listdir(image_dir)
FileNotFoundError: [WinError 3] Systém nemůže nalézt uvedenou cestu: '/test_images/'

So I removed the first slash on line 64: image_dir = os.path.dirname(os.path.dirname(__file__)) + 'test_images/'

Surprisingly, it was enough. =)

loading checkpoint res50.pth
processing (0000)-th image... test_images/038937.png
processing (0001)-th image... test_images/038938.png
processing (0002)-th image... test_images/038939.png
processing (0003)-th image... test_images/038940.png
processing (0004)-th image... test_images/038941.png
processing (0005)-th image... test_images/038942.png
processing (0006)-th image... test_images/038943.png
processing (0007)-th image... test_images/038944.png
processing (0008)-th image... test_images/038945.png

However, I still don't quite understand why Windows require these two changes...

guangkaixu commented 1 year ago

Hi, the "No module named 'lib'" error happens due to the incorrect PYTHONPATH. For ubuntu, we usually solve it by "export PYTHONPATH=...". I didn't run it on windows, and thanks very much for your attempt and give the final solution.