VCIP-RGBD / DFormer

[ICLR 2024] DFormer: Rethinking RGBD Representation Learning for Semantic Segmentation
https://yinbow.github.io/Projects/DFormer/index.html
MIT License
152 stars 24 forks source link

importlib problems #22

Closed johanna27045 closed 5 months ago

johanna27045 commented 5 months ago

I think your approach is very interesting and wanted to try it myself. When setting up the repository I encountered following problem:

File "C:\Users\jk267\DFormer\utils\train.py", line 116, in config = getattr(import_module(args.config), "C") File "C:\Users\jk267.conda\envs\dformer\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "C:\Users\jk267\DFormer.\local_configs\NYUDepthv2\DFormer_Large.py", line 4, in C.backbone = "DFormer-Large" # Remember change the path below. NameError: name 'C' is not defined

I think I may have some package problems, because of not installed packages or libs. Are the installations in readme point 0 all I need and do you have an idea what I could do?

Thank you for your response beforehand.

caojiaolong commented 5 months ago

Thank you for your attention to our work!

It appears that our code behaves differently on a Windows system. Since we do not have access to a Windows machine with graphic cards, it is challenging for us to reproduce this issue. Therefore, we propose two potential solutions:

  1. Change the following line: https://github.com/VCIP-RGBD/DFormer/blob/3dd8a45fb1e294b2c39f0664c66eaeeb385aaa47/train.sh#L10 to

    PYTHONPATH="$(dirname $0) \"

    as the PYTHONPATH structure might be different on Windows.

  2. If the above approach doesn't resolve the issue, there's another workaround. You can manually copy the code from local_configs/_base_/__init__.py and local_configs/_base_/datasets/NYUDepthv2.py into local_configs/NYUDepthv2/DFormer_Large.py. This will create a single large config file. Then, rerun the code.

If the above methods still do not solve the problem, please provide more information so we can try to address the issue.

johanna27045 commented 5 months ago

I apologize for the late answer.

We did change the line with

PYTHONPATH="$(dirname $0)/..":"$(dirname $0)":$PYTHONPATH \

and it worked out. Another thing we noticed was, that there were problems when using only 1 GPU, because the local rank is not set then. We added else: self.local_rank = int(os.environ['LOCAL_RANK']) self.devices = [0, 1] # parse_devices(self.args.devices) in engine.py line 67, 67, 69 and it seems to work out this way.

caojiaolong commented 5 months ago

Thank you for your contribution and pointing out the bugs for us. We have updated the code according to your suggestions.