open-mmlab / mmsegmentation

OpenMMLab Semantic Segmentation Toolbox and Benchmark.
https://mmsegmentation.readthedocs.io/en/main/
Apache License 2.0
8.24k stars 2.61k forks source link

A bug in tools/analysis_tools/get_flops.py #2958

Open ZJLauu opened 1 year ago

ZJLauu commented 1 year ago

Thanks for your error report and we appreciate it a lot.

Checklist

  1. I have searched related issues but cannot get the expected help.
  2. The bug has not been fixed in the latest version.

Describe the bug (ValueError: "input_shape" and "inputs" cannot be both set.) occurs while running tools/analysis_tools/get_flops.py

Reproduction

  1. What command or script did you run?

    python tools/analysis_tools/get_flops.py config.py

    or

    python tools/analysis_tools/get_flops.py config.py --shape (512, 512)
  2. Did you make any modifications on the code or config? Did you understand what you have modified? no

  3. What dataset did you use? customdataset

Environment

  1. Please run python mmseg/utils/collect_env.py to collect necessary environment information and paste it here.

sys.platform: win32 Python: 3.9.0 (default, Nov 15 2020, 08:30:55) [MSC v.1916 64 bit (AMD64)] CUDA available: True numpy_random_seed: 2147483648 GPU 0: NVIDIA GeForce RTX 4080 CUDA_HOME: D:\Program Files\NVIDAI GPU Computing Toolkit\CUDA\v11.8 NVCC: Cuda compilation tools, release 11.8, V11.8.89 MSVC: 用于 x64 的 Microsoft (R) C/C++ 优化编译器 19.35.32216.1 版 GCC: n/a PyTorch: 2.0.0+cu118 PyTorch compiling details: PyTorch built with:

TorchVision: 0.15.1+cu118 OpenCV: 4.7.0 MMEngine: 0.7.2 MMSegmentation: 1.0.0+462fad8

Error traceback

If applicable, paste the error trackback here.

d:\pythonproject\mmsegmentation\mmseg\models\builder.py:36: UserWarning: ``build_loss`` would be deprecated soon, please use ``mmseg.registry.MODELS.build()``
  warnings.warn('``build_loss`` would be deprecated soon, please use '
Traceback (most recent call last):
  File "D:\Pythonproject\mmsegmentation\tools\analysis_tools\get_flops.py", line 124, in <module>
    main()
  File "D:\Pythonproject\mmsegmentation\tools\analysis_tools\get_flops.py", line 104, in main
    result = inference(args, logger)
  File "D:\Pythonproject\mmsegmentation\tools\analysis_tools\get_flops.py", line 87, in inference
    outputs = get_model_complexity_info(
  File "d:\pythonproject\mmengine\mmengine\analysis\print_helper.py", line 725, in get_model_complexity_info
    raise ValueError('"input_shape" and "inputs" cannot be both set.')
ValueError: "input_shape" and "inputs" cannot be both set.

Bug fix

If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!

AI-Tianlong commented 1 year ago

It seems that the issue has been fixed in the latest version. Please update your mmseg to the latest version.

wujiang0156 commented 1 year ago

@xiexinch @AI-Tianlong @ZJLauu I have the same bug and I use the latest version. How to fix image the bug is : image

---->

image Icommented this part of the code:

image or image

the result is image

kaizhong2021 commented 1 year ago

I meet the same error

twsha commented 9 months ago

@xiexinch @AI-Tianlong @ZJLauu I have the same bug and I use the latest version. How to fix image the bug is : image

---->

image Icommented this part of the code:

image or image

the result is image

hi,I also tried my model through the code you modified. The 4-channel input of my model still reported an error after changing the inputs to none. Could it be that the 4-channel cannot be calculated? image