From a9b67f050901b911c0bc010a710f6d135eeaa18a Mon Sep 17 00:00:00 2001 From: yhq Date: Thu, 24 Nov 2022 18:25:27 +0800 Subject: [PATCH] add bevformer benchmark and fix classification predict bug (#240) --- docs/source/model_zoo_det3d.md | 1 + .../multi_scale_deformable_attention.py | 3 +-- easycv/predictors/classifier.py | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/source/model_zoo_det3d.md b/docs/source/model_zoo_det3d.md index 391f5af5..f4d50cf9 100644 --- a/docs/source/model_zoo_det3d.md +++ b/docs/source/model_zoo_det3d.md @@ -7,3 +7,4 @@ Pretrained on [nuScenes](https://www.nuscenes.org/) dataset. | Algorithm | Config | Params
| Train memory
(GB) | NDS | mAP | Download | | ---------- | ------------------------------------------------------------ | ------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | | BEVFormer-base | [bevformer_base_r101_dcn_nuscenes](https://github.com/alibaba/EasyCV/tree/master/configs/detection3d/bevformer/bevformer_base_r101_dcn_nuscenes.py) | 69M | 23.9 | 52.46 | 41.83 | [model](http://pai-vision-data-hz.oss-accelerate.aliyuncs.com/EasyCV/modelzoo/detection3d/bevformer/epoch_24.pth) | +| BEVFormer-base-hybrid | [bevformer_base_r101_dcn_nuscenes_hybrid](https://github.com/alibaba/EasyCV/blob/master/configs/detection3d/bevformer/bevformer_base_r101_dcn_nuscenes_hybrid.py) | 69M | 46.1 | 53.02 | 42.48 | [model](http://pai-vision-data-hz.oss-cn-zhangjiakou.aliyuncs.com/EasyCV/modelzoo/detection3d/bevformer_base_hybrid2/epoch_23.pth) | diff --git a/easycv/models/detection3d/detectors/bevformer/attentions/multi_scale_deformable_attention.py b/easycv/models/detection3d/detectors/bevformer/attentions/multi_scale_deformable_attention.py index eaf16724..61a42a59 100644 --- a/easycv/models/detection3d/detectors/bevformer/attentions/multi_scale_deformable_attention.py +++ b/easycv/models/detection3d/detectors/bevformer/attentions/multi_scale_deformable_attention.py @@ -11,8 +11,6 @@ from mmcv.cnn import constant_init, xavier_init from mmcv.runner.base_module import BaseModule from easycv.models.registry import ATTENTION -from easycv.thirdparty.deformable_attention.functions import \ - MSDeformAttnFunction @ATTENTION.register_module() @@ -99,6 +97,7 @@ class CustomMSDeformableAttention(BaseModule): if self.adapt_jit: self.ms_deform_attn_op = torch.ops.custom.ms_deform_attn else: + from easycv.thirdparty.deformable_attention.functions import MSDeformAttnFunction self.ms_deform_attn_op = MSDeformAttnFunction.apply def init_weights(self): diff --git a/easycv/predictors/classifier.py b/easycv/predictors/classifier.py index a788c354..24170d41 100644 --- a/easycv/predictors/classifier.py +++ b/easycv/predictors/classifier.py @@ -35,10 +35,10 @@ class ClassificationPredictor(PredictorV2): device=None, save_results=False, save_path=None, - pipelines=[], + pipelines=None, topk=1, pil_input=True, - label_map_path=[], + label_map_path=None, *args, **kwargs): super(ClassificationPredictor, self).__init__( @@ -59,7 +59,12 @@ class ClassificationPredictor(PredictorV2): self.INPUT_IMAGE_MODE = 'RGB' if label_map_path is None: - class_list = self.cfg.get('CLASSES', []) + if 'CLASSES' in self.cfg: + class_list = self.cfg.get('CLASSES', []) + elif 'class_list' in self.cfg: + class_list = self.cfg.get('class_list', []) + else: + class_list = [] else: with io.open(label_map_path, 'r') as f: class_list = f.readlines() @@ -85,7 +90,9 @@ class ClassificationPredictor(PredictorV2): img = img.convert(self.INPUT_IMAGE_MODE.upper()) results['filename'] = input else: - assert isinstance(input, ImageFile.ImageFile) + if isinstance(input, np.ndarray): + input = Image.fromarray(input) + # assert isinstance(input, ImageFile.ImageFile) img = input results['filename'] = None results['img'] = img