ImCharlesY / AdaInt

[CVPR 2022] Official PyTorch Implementation of "AdaInt: Learning Adaptive Intervals for 3D Lookup Tables on Real-time Image Enhancement" (https://arxiv.org/abs/2204.13983)
Apache License 2.0
173 stars 19 forks source link

ModuleNotFoundError: No module named 'adaint' #3

Closed sunyclj closed 2 years ago

sunyclj commented 2 years ago

您好,运行demo.py报错ModuleNotFoundError: No module named 'adaint',请问是什么原因?

ImCharlesY commented 2 years ago

你好,

因为你目前提供的信息较少,我还无法对问题原因给出准确定位。

根据已知信息,报错提示找不到adaint模块,然而该模块事实上就位于项目根目录下。因此我暂时怀疑可能是你执行脚本时所在路径不正确。

为便于进一步的分析,我们可能需要一些额外的信息:

  1. 请问你运行demo.py脚本时的系统环境(Windows/Linux)、所在路径以及具体命令行指令?
  2. 请问你是否按照README#Installation中的步骤完成了相关依赖包的安装?如已安装,请提供下几个关键依赖包(mmcv, mmedit)的版本信息。
  3. 如方便复现问题,请给出完整的报错traceback信息,以提供更多参考信息。
sunyclj commented 2 years ago

@ImCharlesY 谢谢. 1、脚本运行环境Linux,运行命令python adaint/demo.py adaint/configs/fivekrgb.py pretrained/AiLUT-FiveK-sRGB.pth resources/a4739.jpg resources/a4739_enhanced.png,运行命令的路径在文件夹AdaInt-main下;运行环境python3.6、pytorch1.7、cuda11.0; 2、依赖包已全部安装,mmcv 1.3.17,mmedit 0.12.0 3、报错信息如下: Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/mmcv/utils/misc.py", line 73, in import_modules_from_strings imported_tmp = import_module(imp) File "/opt/conda/lib/python3.6/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 953, in _find_and_load_unlocked ModuleNotFoundError: No module named 'adaint'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "adaint/demo.py", line 75, in main() File "adaint/demo.py", line 67, in main args.config, args.checkpoint, device=torch.device('cuda', args.device)) File "/opt/conda/lib/python3.6/site-packages/mmedit/apis/matting_inference.py", line 25, in init_model config = mmcv.Config.fromfile(config) File "/opt/conda/lib/python3.6/site-packages/mmcv/utils/config.py", line 334, in fromfile import_modules_from_strings(**cfg_dict['custom_imports']) File "/opt/conda/lib/python3.6/site-packages/mmcv/utils/misc.py", line 80, in import_modules_from_strings raise ImportError ImportError

ImCharlesY commented 2 years ago

@sunyclj 你好,

很抱歉回复晚了。

我注意到你使用的mmedit版本为0.12.0,而本代码库中包含的mmedit库版本应为0.11.0。这说明你目前使用的Python环境中的mmedit库是预先在其他路径下安装的。这会导致本代码库的根目录路径(/PATH/TO/AdaInt)未被添加到Python的包搜索路径(sys.path)中,从而导致执行python adaint/demo.py [options]时找不到adaint模块。

具体原因在于,在README提供的环境配置流程中,pip install -v -e .指令中的-e选项会将mmedit库所在路径添加到Python的包搜索路径中(sys.path)。

你可以考虑通过设置环境变量的方式手动将代码库根目录添加进包搜索路径,如:

PYTHONPATH=./ python adaint/demo.py adaint/configs/fivekrgb.py pretrained/AiLUT-FiveK-sRGB.pth resources/a4739.jpg resources/a4739_enhanced.png

或重新创建一个干净的Python环境,并按照README中的流程重新进行环境配置。

请告知问题是否得到解决。

ImCharlesY commented 2 years ago

I'm going to close this issue. If you have any further questions, please feel free to comment or reopen it.