mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
Fix SDK backend (#844)
This commit is contained in:
parent
a15365e93f
commit
e12dfddc26
@ -139,8 +139,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
list: A list contains predictions.
|
list: A list contains predictions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pred = self.wrapper.invoke(
|
pred = self.wrapper.invoke(img[0].contiguous().detach().cpu().numpy())
|
||||||
[img[0].contiguous().detach().cpu().numpy()])[0]
|
|
||||||
pred = np.array(pred, dtype=np.float32)
|
pred = np.array(pred, dtype=np.float32)
|
||||||
return pred[np.argsort(pred[:, 0])][np.newaxis, :, 1]
|
return pred[np.argsort(pred[:, 0])][np.newaxis, :, 1]
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
list: A list contains predictions.
|
list: A list contains predictions.
|
||||||
"""
|
"""
|
||||||
dets, labels, masks = self.wrapper.invoke(
|
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,
|
det_results = bbox2result(dets[np.newaxis, ...], labels[np.newaxis,
|
||||||
...],
|
...],
|
||||||
len(self.CLASSES))
|
len(self.CLASSES))
|
||||||
|
@ -223,7 +223,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
list | dict: High resolution image or a evaluation results.
|
list | dict: High resolution image or a evaluation results.
|
||||||
"""
|
"""
|
||||||
img = tensor2img(lq)
|
img = tensor2img(lq)
|
||||||
output = self.wrapper.invoke([img])[0]
|
output = self.wrapper.invoke(img)
|
||||||
if test_mode:
|
if test_mode:
|
||||||
output = torch.from_numpy(output)
|
output = torch.from_numpy(output)
|
||||||
output = output.permute(2, 0, 1)
|
output = output.permute(2, 0, 1)
|
||||||
|
@ -169,7 +169,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
list: A list contains predictions.
|
list: A list contains predictions.
|
||||||
"""
|
"""
|
||||||
boundaries = self.wrapper.invoke(
|
boundaries = self.wrapper.invoke(
|
||||||
[img[0].contiguous().detach().cpu().numpy()])[0]
|
img[0].contiguous().detach().cpu().numpy())
|
||||||
boundaries = [list(x) for x in boundaries]
|
boundaries = [list(x) for x in boundaries]
|
||||||
return [
|
return [
|
||||||
dict(
|
dict(
|
||||||
|
@ -181,9 +181,9 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
Returns:
|
Returns:
|
||||||
list[str]: Text label result of each image.
|
list[str]: Text label result of each image.
|
||||||
"""
|
"""
|
||||||
results = self.wrapper.invoke(
|
text, score = self.wrapper.invoke(
|
||||||
[img[0].contiguous().detach().cpu().numpy()])
|
img[0].contiguous().detach().cpu().numpy())
|
||||||
results = [dict(text=text, score=score) for text, score in results]
|
results = [dict(text=text, score=score)]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
@ -218,8 +218,8 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
image_paths.append(img_meta['image_file'])
|
image_paths.append(img_meta['image_file'])
|
||||||
bbox_ids.append(img_meta['bbox_id'])
|
bbox_ids.append(img_meta['bbox_id'])
|
||||||
|
|
||||||
pred = self.wrapper.handle(
|
pred = self.wrapper.handle(img[0].contiguous().detach().cpu().numpy(),
|
||||||
[img[0].contiguous().detach().cpu().numpy()], [sdk_boxes])[0]
|
sdk_boxes)
|
||||||
|
|
||||||
result = dict(
|
result = dict(
|
||||||
preds=pred,
|
preds=pred,
|
||||||
|
@ -212,7 +212,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
"""
|
"""
|
||||||
results = []
|
results = []
|
||||||
dets, labels = self.wrapper.invoke(
|
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))]
|
dets_results = [dets[labels == i, :] for i in range(len(self.CLASSES))]
|
||||||
results.append(dets_results)
|
results.append(dets_results)
|
||||||
|
|
||||||
|
@ -166,8 +166,7 @@ class SDKEnd2EndModel(End2EndModel):
|
|||||||
Returns:
|
Returns:
|
||||||
list: A list contains predictions.
|
list: A list contains predictions.
|
||||||
"""
|
"""
|
||||||
masks = self.wrapper.invoke(
|
masks = self.wrapper.invoke(img[0].contiguous().detach().cpu().numpy())
|
||||||
[img[0].contiguous().detach().cpu().numpy()])[0]
|
|
||||||
return masks
|
return masks
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user