RaymondWang987 / NVDS

ICCV 2023 "Neural Video Depth Stabilizer" (NVDS) & TPAMI 2024 "NVDS+: Towards Efficient and Versatile Neural Stabilizer for Video Depth Estimation" (NVDS+)
MIT License
471 stars 24 forks source link

Running NVDS in Windows...? #17

Open vitacon opened 11 months ago

vitacon commented 11 months ago

Did anyone try to run NVDS in Windows? I suspect it is not that easy because of GMFlow...

igor-kurenkov commented 11 months ago

Yep, i can't get GMflow istalled, conda environment.yml fails installing libs, would appreciate help

vitacon commented 11 months ago

Yep, i can't get GMflow istalled, conda environment.yml fails installing libs, would appreciate help

Thanks for your confirmation. I don't think there is an easy way around it. =(

I wanted to test Unimatch (GMFlow successor) some time ago and it required too many libraries that don't exist for Windows. https://github.com/autonomousvision/unimatch/issues/38

I suppose it would require a massive rewrite of the project.

RaymondWang987 commented 11 months ago

Did anyone try to run NVDS in Windows? I suspect it is not that easy because of GMFlow...

I have not tried to install GMflow on Windows. I think you can simply remove all the GMflow parts in our code. The GMflow is only used to evaluate the temporal metric OPW during the inference of NVDS. Removing the GMflow and the OPW evaluation code will not influence the prediction process of NVDS.

vitacon commented 11 months ago

The GMflow is only used to evaluate the temporal metric OPW during the inference of NVDS. Removing the GMflow and the OPW evaluation code will not influence the prediction process of NVDS.

Um, I'm not sure I understand it correctly. I suppose GMflow is used to improve temporal consistency so leaving it out will degrade the consistency...?

RaymondWang987 commented 11 months ago

The GMflow is only used to evaluate the temporal metric OPW during the inference of NVDS. Removing the GMflow and the OPW evaluation code will not influence the prediction process of NVDS.

Um, I'm not sure I understand it correctly. I suppose GMflow is used to improve temporal consistency so leaving it out will degrade the consistency...?

GMflow is not used in the inference stage of NVDS. It is used in the training stage (the temporal loss) and the OPW metric evaluations. The NVDS does not rely on GMFlow for predictions. Removing the GMFlow and OPW evaluation in the inference code won't degrade the performance.

vitacon commented 11 months ago

Thanks for the explanation! @RaymondWang987

zhanghongyong123456 commented 11 months ago

Thanks for the explanation! @RaymondWang987

for me,I just installed the project's environment and was able to run the GMflow project

conda create -n NVDS python=3.8.13 conda activate NVDS conda install pytorch==1.9.0 torchvision==0.10.0 cudatoolkit=11.1 -c pytorch -c conda-forge pip install numpy imageio opencv-python scipy tensorboard timm scikit-image tqdm h5py

remove glob , (My VS: 2019, nvcc -V :Cuda compilation tools, release 11.7, V11.7.64 Build cuda_11.7.r11.7/compiler.31294372_0 ) than run pip install -U openmim mim install mmcv-full==1.3.0 finally
pip install mmsegmentation==0.11.0 and other libs: pip install attr IPython einops
mybe need change setuptools version 60.2 to 59.5.0(if have version errorAttributeError: module ‘setuptools._distutils‘ has no attribute ‘version‘)

vitacon commented 11 months ago

I am not sure why I had to install some stuff separately but it was the last thing I needed to do:

  conda install matplotlib
  conda install scipy
  conda install -c conda-forge timm

DPT test runs fine:

(NVDS) C:\Users\Vita\video\nvds>python infer_NVDS_dpt_bi.py --base_dir ./demo_outputs/midas_init/motocross-jump/ --vnum motocross-jump --infer_w 672 --infer_h 384

Unfortunately MiDaS test crashes:

(NVDS) C:\Users\Vita\video\nvds>python infer_NVDS_midas_bi.py --base_dir ./demo_outputs/midas_init/motocross-jump/ --vnum motocross-jump --infer_w 672 --infer_h 384
let us begin test NVDS(MiDaS)
Load checkpoint: ./gmflow/checkpoints/gmflow_sintel-0c07dcb3.pth
******self.shift_size:  0
here mask none
******self.shift_size:  0
here mask none
******self.shift_size:  0
here mask none
******self.shift_size:  0
here mask none
Loading weights:  ./dpt/checkpoints/midas_v21-f6b98070.pt
Traceback (most recent call last):
  File "infer_NVDS_midas_bi.py", line 358, in <module>
    dpt = MidasNet_large('./dpt/checkpoints/midas_v21-f6b98070.pt', non_negative=True).to(device_flow)
  File "C:\Users\Vita\video\nvds\dpt\midas_net.py", line 29, in __init__
    self.pretrained, self.scratch = _make_encoder(
  File "C:\Users\Vita\video\nvds\dpt\blocks.py", line 56, in _make_encoder
    pretrained = _make_pretrained_resnext101_wsl(use_pretrained)
  File "C:\Users\Vita\video\nvds\dpt\blocks.py", line 134, in _make_pretrained_resnext101_wsl
    resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\site-packages\torch\hub.py", line 362, in load
    repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\site-packages\torch\hub.py", line 162, in _get_cache_or_reload
    _validate_not_a_forked_repo(repo_owner, repo_name, branch)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\site-packages\torch\hub.py", line 124, in _validate_not_a_forked_repo
    with urlopen(url) as r:
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 640, in http_response
    response = self.parent.error(
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 502, in _call_chain
    result = func(*args)
  File "C:\Users\Vita\Anaconda3\envs\NVDS\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: rate limit exceeded

I thought it couldn't load the weights but the file is already in its place.

 Directory of C:\Users\Vita\video\nvds\dpt\checkpoints

02.11.2023  20:00    <DIR>          .
02.11.2023  20:00    <DIR>          ..
28.10.2023  17:06     1 376 378 527 dpt_large-midas-2f21e586.pt
28.10.2023  17:01       422 509 849 midas_v21-f6b98070.pt
28.10.2023  17:01       422 509 849 midas_v21_384.pt
24.09.2023  08:36                 0 placeholder.txt

What am I missing?

vitacon commented 11 months ago

Hm...

resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")

www.stackoverflow.com/questions/68901236/urllib-error-httperror-http-error-403-rate-limit-exceeded-when-loading-resnet1

vitacon commented 11 months ago

FYI: it seems the link above was right. There is a bug in pytorch 1.9.0 and you should either update pytorch to 1.9.1 or modify the source. I did the later in blocks.py and now it runs fine:

def _make_pretrained_resnext101_wsl(use_pretrained):
    torch.hub._validate_not_a_forked_repo=lambda a,b,c: True # add this line!
    resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")
    return _make_resnet_backbone(resnet)

I just wonder why other people did not have the same problem...

MrMello7 commented 11 months ago

FYI: it seems the link above was right. There is a bug in pytorch 1.9.0 and you should either update pytorch to 1.9.1 or modify the source. I did the later in blocks.py and now it runs fine:

def _make_pretrained_resnext101_wsl(use_pretrained):
    torch.hub._validate_not_a_forked_repo=lambda a,b,c: True # add this line!
    resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")
    return _make_resnet_backbone(resnet)

I just wonder why other people did not have the same problem...

It's not just you who encountered the problem. I want to install GMFlow on Windows, but there seems to be a problem with environment.yml. Have you found a solution?

vitacon commented 11 months ago

It's not just you who encountered the problem. I want to install GMFlow on Windows, but there seems to be a problem with environment.yml. Have you found a solution? @xiyelong

Well, these are two diffent problems. As you can see above: GMFlow is not used in the inference stage of NVDS.

So to use NVDS just for generation of depth maps GMFlow is not needed and I don't think I will try training it myself.

Anyway, I think it's a question that should be answered by GMFlow authors.

MrMello7 commented 11 months ago

It's not just you who encountered the problem. I want to install GMFlow on Windows, but there seems to be a problem with environment.yml. Have you found a solution? @xiyelong

Well, these are two diffent problems. As you can see above: GMFlow is not used in the inference stage of NVDS.

So to use NVDS just for generation of depth maps GMFlow is not needed and I don't think I will try training it myself.

Anyway, I think it's a question that should be answered by GMFlow authors.

Thank you for your reply. I gave up creating an environment under Win10 and instead used a Linux server, which is very easy to create. I think the author may not have thought that his program would run under Windows :)