open-mmlab / mmsegmentation

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

When reproducing the model, add --eval mAP, display parameters, AttributeError:'tuple' object has no attribute'shape' appears Do not add --eval, you can reproduce #947

Closed sd-spf closed 3 years ago

sd-spf commented 3 years ago

If you feel we have helped you, give us a STAR! :satisfied:

Checklist

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

Describe the issue

AttributeError: 'tuple' object has no attribute 'shape', In addition, if I want to display the indicators of the categories in cityspaces, how to add parameters

Environment dataset cityscapes config fcn GCC: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0 PyTorch: 1.6.0 TorchVision: 0.7.0 OpenCV: 4.5.3 MMCV: 1.3.14 MMCV Compiler: GCC 7.3 MMCV CUDA Compiler: 10.1 MMSegmentation: 0.18.0+ CUDA Runtime 10.1 CuDNN 7.6.3 Python: 3.7.0 (default, Oct 9 2018, 10:31:47) [GCC 7.3.0]

Results

If applicable, paste the related results here, e.g., what you expect and what you get.

/home/amax/.conda/envs/mmseg/bin/python /home/amax/share/SPF/mmsegmentation-master/tools/test.py ../configs/fcn/fcn_r18b-d8_769x769_80k_cityscapes.py ../checkpoints/fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-dir fcn_r18b-d8_769x769_80k_cityscapes_results --eval mAP
2021-10-09 17:28:09,306 - mmseg - INFO - Loaded 500 images
Use load_from_local loader
[                                                  ] 0/500, elapsed: 0s, ETA:Traceback (most recent call last):
  File "/home/amax/share/SPF/mmsegmentation-master/tools/test.py", line 229, in <module>
    main()
  File "/home/amax/share/SPF/mmsegmentation-master/tools/test.py", line 191, in main
    format_args=eval_kwargs)
  File "/home/amax/share/SPF/mmsegmentation-master/mmseg/apis/test.py", line 130, in single_gpu_test
    opacity=opacity)
  File "/home/amax/share/SPF/mmsegmentation-master/mmseg/models/segmentors/base.py", line 246, in show_result
    color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8)
AttributeError: 'tuple' object has no attribute 'shape'
MengzhangLI commented 3 years ago

Hi, right now metric only support ['mIoU', 'mDice', 'mFscore']

sd-spf commented 3 years ago

(mmseg) amax@ict2:~/share/SPF/mmsegmentation-master$ python tools/test.py configs/fcn/fcn_r18b-d8_769x769_80k_cityscapes.py checkpoints/fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-dir fcn_r18b-d8_769x769_80k_cityscapes_results --eval mIoU 2021-10-10 11:55:50,475 - mmseg - INFO - Loaded 500 images Use load_from_local loader [ ] 0/500, elapsed: 0s, ETA:Traceback (most recent call last): File "tools/test.py", line 229, in main() File "tools/test.py", line 191, in main format_args=eval_kwargs) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/apis/test.py", line 130, in single_gpu_test opacity=opacity) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/models/segmentors/base.py", line 246, in show_result color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) AttributeError: 'tuple' object has no attribute 'shape'

Still the same error

嗨,现在指标只支持 ['mIoU', 'mDice', 'mFscore']

dreamerwyx commented 3 years ago

(mmseg) amax@ict2:~/share/SPF/mmsegmentation-master$ python tools/test.py configs/fcn/fcn_r18b-d8_769x769_80k_cityscapes.py checkpoints/fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-dir fcn_r18b-d8_769x769_80k_cityscapes_results --eval mIoU 2021-10-10 11:55:50,475 - mmseg - INFO - Loaded 500 images Use load_from_local loader [ ] 0/500, elapsed: 0s, ETA:Traceback (most recent call last): File "tools/test.py", line 229, in main() File "tools/test.py", line 191, in main format_args=eval_kwargs) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/apis/test.py", line 130, in single_gpu_test opacity=opacity) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/models/segmentors/base.py", line 246, in show_result color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) AttributeError: 'tuple' object has no attribute 'shape'

Still the same error

嗨,现在指标只支持 ['mIoU', 'mDice', 'mFscore']

hi, you can try like this: modify:mmseg/models/segmentors/base.py Line 246:

color_seg = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)

or comment out: mmseg/apis/test.py Line 124-130: This will not get the picture, only the evaluate result.

My result is like this:

2021-09-27 14:00:58,146 - mmseg - INFO - Loaded 1449 images
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 1449/1449, 1.1 task/s, elapsed: 1311s, ETA:     0s

writing results to ./output/gcnet_r50-d8_512x512_20k_voc12aug_res.pkl
per class results:

+-------------+-------+-------+
|    Class    |  IoU  |  Acc  |
+-------------+-------+-------+
|  background | 93.97 |  97.1 |
|  aeroplane  | 89.33 | 94.08 |
|   bicycle   | 39.87 | 91.54 |
|     bird    | 85.78 | 93.17 |
|     boat    | 68.88 | 90.08 |
|    bottle   | 73.58 |  83.6 |
|     bus     | 94.05 | 97.34 |
|     car     | 87.41 | 92.14 |
|     cat     |  92.0 | 95.94 |
|    chair    | 30.97 | 50.27 |
|     cow     | 86.08 | 95.96 |
| diningtable | 57.57 | 60.94 |
|     dog     |  86.9 | 94.05 |
|    horse    | 85.91 | 94.31 |
|  motorbike  | 82.95 |  89.3 |
|    person   | 84.48 |  91.0 |
| pottedplant | 59.29 |  68.3 |
|    sheep    | 80.29 | 83.43 |
|     sofa    | 43.02 | 52.41 |
|    train    |  87.5 | 93.68 |
|  tvmonitor  | 68.97 | 77.97 |
+-------------+-------+-------+
Summary:

+-------+-------+-------+
|  aAcc |  mIoU |  mAcc |
+-------+-------+-------+
| 94.36 | 75.18 | 85.08 |
+-------+-------+-------+
sd-spf commented 3 years ago

(mmseg)λ@ ICT 2:〜/股/ SPF / mmsegmentation主$ Python工具/ test.py CONFIGS / FCN / fcn_r18b-d8_769x769_80k_cityscapes.py检查点/ fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-DIR fcn_r18b-d8_769x769_80k_cityscapes_results - -eval mIoU 2021-10-10 11:55:50,475 - mmseg - INFO - 加载了 500 张图像使用 load_from_local loader [ ] 0/500, elapsed: 0s, ETA:Traceback (最近一次调用最后一次): File "tools/test. py", line 229, in main() 文件 "tools/test.py", line 191, in main format_args=eval_kwargs) 文件 "/home/amax/.conda/envs/mmseg/lib/python3.7/site- package/mmseg/apis/test.py", line 130, in single_gpu_test opacity=opacity) 文件 "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/models/segmentors/ base.py”,第 246 行,在 show_result color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) AttributeError: 'tuple' 对象没有属性 'shape' 还是一样的错误

嗨,现在指标只支持['mIoU', 'mDice', 'mFscore']

你好,你可以这样试试: 修改:mmseg/models/segmentors/base.py 第246行:

color_seg  =  np。零((IMG。形状[ 0 ],IMG。形状[ 1 ],3),D型细胞= NP。UINT8)

或者 注释掉: mmseg/apis/test.py Line 124-130: 这不会得到图片,只有评估结果。

我的结果是这样的:

2021-09-27 14:00:58,146 - mmseg - INFO - Loaded 1449 images
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 1449/1449, 1.1 task/s, elapsed: 1311s, ETA:     0s

writing results to ./output/gcnet_r50-d8_512x512_20k_voc12aug_res.pkl
per class results:

+-------------+-------+-------+
|    Class    |  IoU  |  Acc  |
+-------------+-------+-------+
|  background | 93.97 |  97.1 |
|  aeroplane  | 89.33 | 94.08 |
|   bicycle   | 39.87 | 91.54 |
|     bird    | 85.78 | 93.17 |
|     boat    | 68.88 | 90.08 |
|    bottle   | 73.58 |  83.6 |
|     bus     | 94.05 | 97.34 |
|     car     | 87.41 | 92.14 |
|     cat     |  92.0 | 95.94 |
|    chair    | 30.97 | 50.27 |
|     cow     | 86.08 | 95.96 |
| diningtable | 57.57 | 60.94 |
|     dog     |  86.9 | 94.05 |
|    horse    | 85.91 | 94.31 |
|  motorbike  | 82.95 |  89.3 |
|    person   | 84.48 |  91.0 |
| pottedplant | 59.29 |  68.3 |
|    sheep    | 80.29 | 83.43 |
|     sofa    | 43.02 | 52.41 |
|    train    |  87.5 | 93.68 |
|  tvmonitor  | 68.97 | 77.97 |
+-------------+-------+-------+
Summary:

+-------+-------+-------+
|  aAcc |  mIoU |  mAcc |
+-------+-------+-------+
| 94.36 | 75.18 | 85.08 |
+-------+-------+-------+
sd-spf commented 3 years ago

(mmseg)λ@ ICT 2:〜/股/ SPF / mmsegmentation主$ Python的工具/ test.py CONFIGS / FCN / fcn_r18b-d8_769x769_80k_cityscapes.py检查点/ fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-DIR fcn_r18b-d8_769x769_80k_cityscapes_results - -eval mIoU 2021-10-10 11:55:50,475 - mmseg - INFO - 加载了 500 张图像使用 load_from_local loader [ ] 0/500, elapsed: 0s, ETA:Traceback (最后一次调用最后一次): File " tools/test.py", line 229, in main() 文件 "tools/test.py", line 191, in main format_args=eval_kwargs) 文件 "/home/amax/.conda/envs/mmseg/lib/python3. 7/site- package/mmseg/apis/test.py", line 130, in single_gpu_test opacity=opacity) 文件 "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/ models/segmentors/ base.py”,第246行,在show_result color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) AttributeError: 'tuple' 对象没有属性 'shape' 还是一样的错误

嗨,现在指标只支持['mIoU', 'mDice', 'mFscore']

你好,你可以这样聪明: 修改:mmseg/models/segmentors/base.py 第246行:

color_seg   =   NP。零((IMG。形状[ 0 ],IMG。形状[ 1 ],3),d型细胞=  NP。UINT8)

或者注释掉:mmseg/apis/test.py 第 124-130 行:这不会得到图片,只有评估结果。 我的结果是这样的:

2021-09-27 14:00:58,146 - mmseg - INFO - Loaded 1449 images
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 1449/1449, 1.1 task/s, elapsed: 1311s, ETA:     0s

writing results to ./output/gcnet_r50-d8_512x512_20k_voc12aug_res.pkl
per class results:

+-------------+-------+-------+
|    Class    |  IoU  |  Acc  |
+-------------+-------+-------+
|  background | 93.97 |  97.1 |
|  aeroplane  | 89.33 | 94.08 |
|   bicycle   | 39.87 | 91.54 |
|     bird    | 85.78 | 93.17 |
|     boat    | 68.88 | 90.08 |
|    bottle   | 73.58 |  83.6 |
|     bus     | 94.05 | 97.34 |
|     car     | 87.41 | 92.14 |
|     cat     |  92.0 | 95.94 |
|    chair    | 30.97 | 50.27 |
|     cow     | 86.08 | 95.96 |
| diningtable | 57.57 | 60.94 |
|     dog     |  86.9 | 94.05 |
|    horse    | 85.91 | 94.31 |
|  motorbike  | 82.95 |  89.3 |
|    person   | 84.48 |  91.0 |
| pottedplant | 59.29 |  68.3 |
|    sheep    | 80.29 | 83.43 |
|     sofa    | 43.02 | 52.41 |
|    train    |  87.5 | 93.68 |
|  tvmonitor  | 68.97 | 77.97 |
+-------------+-------+-------+
Summary:

+-------+-------+-------+
|  aAcc |  mIoU |  mAcc |
+-------+-------+-------+
| 94.36 | 75.18 | 85.08 |
+-------+-------+-------+

This is ok, thank you very much

MengzhangLI commented 3 years ago

(mmseg) amax@ict2:~/share/SPF/mmsegmentation-master$ python tools/test.py configs/fcn/fcn_r18b-d8_769x769_80k_cityscapes.py checkpoints/fcn_r18b-d8_769x769_80k_cityscapes_20201226_004430-32d504e5.pth --show-dir fcn_r18b-d8_769x769_80k_cityscapes_results --eval mIoU 2021-10-10 11:55:50,475 - mmseg - INFO - Loaded 500 images Use load_from_local loader [ ] 0/500, elapsed: 0s, ETA:Traceback (most recent call last): File "tools/test.py", line 229, in main() File "tools/test.py", line 191, in main format_args=eval_kwargs) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/apis/test.py", line 130, in single_gpu_test opacity=opacity) File "/home/amax/.conda/envs/mmseg/lib/python3.7/site-packages/mmseg/models/segmentors/base.py", line 246, in show_result color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) AttributeError: 'tuple' object has no attribute 'shape' Still the same error

嗨,现在指标只支持 ['mIoU', 'mDice', 'mFscore']

hi, you can try like this: modify:mmseg/models/segmentors/base.py Line 246:

color_seg = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8)

or comment out: mmseg/apis/test.py Line 124-130: This will not get the picture, only the evaluate result.

My result is like this:

2021-09-27 14:00:58,146 - mmseg - INFO - Loaded 1449 images
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 1449/1449, 1.1 task/s, elapsed: 1311s, ETA:     0s

writing results to ./output/gcnet_r50-d8_512x512_20k_voc12aug_res.pkl
per class results:

+-------------+-------+-------+
|    Class    |  IoU  |  Acc  |
+-------------+-------+-------+
|  background | 93.97 |  97.1 |
|  aeroplane  | 89.33 | 94.08 |
|   bicycle   | 39.87 | 91.54 |
|     bird    | 85.78 | 93.17 |
|     boat    | 68.88 | 90.08 |
|    bottle   | 73.58 |  83.6 |
|     bus     | 94.05 | 97.34 |
|     car     | 87.41 | 92.14 |
|     cat     |  92.0 | 95.94 |
|    chair    | 30.97 | 50.27 |
|     cow     | 86.08 | 95.96 |
| diningtable | 57.57 | 60.94 |
|     dog     |  86.9 | 94.05 |
|    horse    | 85.91 | 94.31 |
|  motorbike  | 82.95 |  89.3 |
|    person   | 84.48 |  91.0 |
| pottedplant | 59.29 |  68.3 |
|    sheep    | 80.29 | 83.43 |
|     sofa    | 43.02 | 52.41 |
|    train    |  87.5 | 93.68 |
|  tvmonitor  | 68.97 | 77.97 |
+-------------+-------+-------+
Summary:

+-------+-------+-------+
|  aAcc |  mIoU |  mAcc |
+-------+-------+-------+
| 94.36 | 75.18 | 85.08 |
+-------+-------+-------+

Good job, thanks for your help!