open-mmlab / mmsegmentation

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

ValueError: "input_shape" and "inputs" cannot be both set. #3241

Open londumas opened 1 year ago

londumas commented 1 year ago

The following error lines can be corrected:

Traceback (most recent call last):
  File "<here>/mmsegmentation/tools/analysis_tools/get_flops.py", line 124, in <module>
    main()
  File "<here>/workspace/mmsegmentation/tools/analysis_tools/get_flops.py", line 98, in main
    result = inference(args, logger)
  File "<here>/workspace/mmsegmentation/tools/analysis_tools/get_flops.py", line 85, in inference
    outputs = get_model_complexity_info(
  File "<me>/.local/lib/python3.10/site-packages/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.

These lines: https://github.com/open-mmlab/mmsegmentation/blob/30a3f94f3e2916e27fa38c67cc3b8c69c1893fe8/tools/analysis_tools/get_flops.py#L87

should be replaced by:

    outputs = get_model_complexity_info(
        model,
        inputs=data['inputs'],
        show_table=False,
        show_arch=False)
AnRanbel commented 1 year ago

@londumas I have encountered the same problem using the latest version of mmseg, which has been modified according to your way and solved, thank you!