From e12dfddc26f9cc4b1c448c01a390287bfd9a5435 Mon Sep 17 00:00:00 2001 From: Chen Xin Date: Tue, 2 Aug 2022 11:49:25 +0800 Subject: [PATCH] Fix SDK backend (#844) --- mmdeploy/codebase/mmcls/deploy/classification_model.py | 3 +-- mmdeploy/codebase/mmdet/deploy/object_detection_model.py | 2 +- mmdeploy/codebase/mmedit/deploy/super_resolution_model.py | 2 +- mmdeploy/codebase/mmocr/deploy/text_detection_model.py | 2 +- mmdeploy/codebase/mmocr/deploy/text_recognition_model.py | 6 +++--- mmdeploy/codebase/mmpose/deploy/pose_detection_model.py | 4 ++-- .../codebase/mmrotate/deploy/rotated_detection_model.py | 2 +- mmdeploy/codebase/mmseg/deploy/segmentation_model.py | 3 +-- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/mmdeploy/codebase/mmcls/deploy/classification_model.py b/mmdeploy/codebase/mmcls/deploy/classification_model.py index 915550d06..6ebd8d520 100644 --- a/mmdeploy/codebase/mmcls/deploy/classification_model.py +++ b/mmdeploy/codebase/mmcls/deploy/classification_model.py @@ -139,8 +139,7 @@ class SDKEnd2EndModel(End2EndModel): list: A list contains predictions. """ - pred = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()])[0] + pred = self.wrapper.invoke(img[0].contiguous().detach().cpu().numpy()) pred = np.array(pred, dtype=np.float32) return pred[np.argsort(pred[:, 0])][np.newaxis, :, 1] diff --git a/mmdeploy/codebase/mmdet/deploy/object_detection_model.py b/mmdeploy/codebase/mmdet/deploy/object_detection_model.py index a9af63351..26f7185cf 100644 --- a/mmdeploy/codebase/mmdet/deploy/object_detection_model.py +++ b/mmdeploy/codebase/mmdet/deploy/object_detection_model.py @@ -637,7 +637,7 @@ class SDKEnd2EndModel(End2EndModel): list: A list contains predictions. """ dets, labels, masks = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()])[0] + img[0].contiguous().detach().cpu().numpy()) det_results = bbox2result(dets[np.newaxis, ...], labels[np.newaxis, ...], len(self.CLASSES)) diff --git a/mmdeploy/codebase/mmedit/deploy/super_resolution_model.py b/mmdeploy/codebase/mmedit/deploy/super_resolution_model.py index 933390ce7..85d44cf99 100644 --- a/mmdeploy/codebase/mmedit/deploy/super_resolution_model.py +++ b/mmdeploy/codebase/mmedit/deploy/super_resolution_model.py @@ -223,7 +223,7 @@ class SDKEnd2EndModel(End2EndModel): list | dict: High resolution image or a evaluation results. """ img = tensor2img(lq) - output = self.wrapper.invoke([img])[0] + output = self.wrapper.invoke(img) if test_mode: output = torch.from_numpy(output) output = output.permute(2, 0, 1) diff --git a/mmdeploy/codebase/mmocr/deploy/text_detection_model.py b/mmdeploy/codebase/mmocr/deploy/text_detection_model.py index 9c42b70b0..561acef17 100644 --- a/mmdeploy/codebase/mmocr/deploy/text_detection_model.py +++ b/mmdeploy/codebase/mmocr/deploy/text_detection_model.py @@ -169,7 +169,7 @@ class SDKEnd2EndModel(End2EndModel): list: A list contains predictions. """ boundaries = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()])[0] + img[0].contiguous().detach().cpu().numpy()) boundaries = [list(x) for x in boundaries] return [ dict( diff --git a/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py b/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py index e5f1fb896..a8eca743c 100644 --- a/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py +++ b/mmdeploy/codebase/mmocr/deploy/text_recognition_model.py @@ -181,9 +181,9 @@ class SDKEnd2EndModel(End2EndModel): Returns: list[str]: Text label result of each image. """ - results = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()]) - results = [dict(text=text, score=score) for text, score in results] + text, score = self.wrapper.invoke( + img[0].contiguous().detach().cpu().numpy()) + results = [dict(text=text, score=score)] return results diff --git a/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py b/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py index ffc6f5a1c..8d6e28eb2 100644 --- a/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py +++ b/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py @@ -218,8 +218,8 @@ class SDKEnd2EndModel(End2EndModel): image_paths.append(img_meta['image_file']) bbox_ids.append(img_meta['bbox_id']) - pred = self.wrapper.handle( - [img[0].contiguous().detach().cpu().numpy()], [sdk_boxes])[0] + pred = self.wrapper.handle(img[0].contiguous().detach().cpu().numpy(), + sdk_boxes) result = dict( preds=pred, diff --git a/mmdeploy/codebase/mmrotate/deploy/rotated_detection_model.py b/mmdeploy/codebase/mmrotate/deploy/rotated_detection_model.py index f864e17d9..0d25261a6 100644 --- a/mmdeploy/codebase/mmrotate/deploy/rotated_detection_model.py +++ b/mmdeploy/codebase/mmrotate/deploy/rotated_detection_model.py @@ -212,7 +212,7 @@ class SDKEnd2EndModel(End2EndModel): """ results = [] dets, labels = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()])[0] + img[0].contiguous().detach().cpu().numpy()) dets_results = [dets[labels == i, :] for i in range(len(self.CLASSES))] results.append(dets_results) diff --git a/mmdeploy/codebase/mmseg/deploy/segmentation_model.py b/mmdeploy/codebase/mmseg/deploy/segmentation_model.py index 8afe220cb..78e8d69b6 100644 --- a/mmdeploy/codebase/mmseg/deploy/segmentation_model.py +++ b/mmdeploy/codebase/mmseg/deploy/segmentation_model.py @@ -166,8 +166,7 @@ class SDKEnd2EndModel(End2EndModel): Returns: list: A list contains predictions. """ - masks = self.wrapper.invoke( - [img[0].contiguous().detach().cpu().numpy()])[0] + masks = self.wrapper.invoke(img[0].contiguous().detach().cpu().numpy()) return masks