无法import show_result的问题
MMDetection教程,我们可以发现很多教程都有这样一句:
from mmdet.apis import init_detector, inference_detector, show_result
在2020年4月29号的commit #e8117f0中,这个show_result(img, result, class_names, ...)
方法被从该模块中重构掉了(因为与mmdet/models/detectors/base.py
中BaseDetector
类的同名方法重复)。
解决办法:
- 如果不希望重新安装mmdetection的老版本,可以把代码中所有的show_result(img, result,class_names, …)替换为model.show_result(img, result, …) 。
- 如果不希望修改已有的代码,可以重新安装mmdetection 1.2.0或更早的版本。
- 使用BaseDetector里面的show_result函数:
https://github.com/open-mmlab/mmdetection/issues/3771
上面方法我试了不行。。。
下面这个可行,注意参数顺序!!!
from mmdet.apis import inference_detector, init_detector, show_result_pyplot
.
.
.
show_result_pyplot(model, img, result)