Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] fix sdk backend when use tools/test.py #844

Merged
merged 1 commit into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions mmdeploy/codebase/mmcls/deploy/classification_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ def forward(self, img: List[torch.Tensor], *args, **kwargs) -> list:
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]

Expand Down
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmdet/deploy/object_detection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def forward(self, img: Sequence[torch.Tensor], img_metas: Sequence[dict],
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))
Expand Down
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmedit/deploy/super_resolution_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def forward(self,
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)
Expand Down
2 changes: 1 addition & 1 deletion mmdeploy/codebase/mmocr/deploy/text_detection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def forward(self, img: Sequence[torch.Tensor],
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(
Expand Down
6 changes: 3 additions & 3 deletions mmdeploy/codebase/mmocr/deploy/text_recognition_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def forward(self, img: Sequence[torch.Tensor],
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


Expand Down
4 changes: 2 additions & 2 deletions mmdeploy/codebase/mmpose/deploy/pose_detection_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ def forward(self, img: List[torch.Tensor], *args, **kwargs) -> list:
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def forward(self, img: List[torch.Tensor], *args, **kwargs) -> list:
"""
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)

Expand Down
3 changes: 1 addition & 2 deletions mmdeploy/codebase/mmseg/deploy/segmentation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ def forward(self, img: Sequence[torch.Tensor],
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


Expand Down