Skip to content

Commit

Permalink
bugfix (#2581)
Browse files Browse the repository at this point in the history
  • Loading branch information
flytocc committed Dec 21, 2023
1 parent 97c1dc5 commit 9ccf2f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions csrc/mmdeploy/codebase/mmdet/instance_segmentation.cpp
Expand Up @@ -145,8 +145,8 @@ class ResizeInstanceMask : public ResizeBBox {
OUTCOME_TRY(auto cpu_mask, MakeAvailableOnDevice(d_mask, host, stream_));
OUTCOME_TRY(stream().Wait());
cv::Mat mask_mat(mask_height, mask_width, CV_32FC(mask_channel), cpu_mask.data());
int resize_height = int(mask_height / scale_factor_[0] + 0.5);
int resize_width = int(mask_width / scale_factor_[1] + 0.5);
int resize_height = int(mask_height / scale_factor_[1] + 0.5);
int resize_width = int(mask_width / scale_factor_[0] + 0.5);
// skip resize if scale_factor is 1.0
if (resize_height != mask_height || resize_width != mask_width) {
cv::resize(mask_mat, mask_mat, cv::Size(resize_width, resize_height), cv::INTER_LINEAR);
Expand Down
8 changes: 4 additions & 4 deletions mmdeploy/codebase/mmdet/deploy/object_detection_model.py
Expand Up @@ -225,8 +225,8 @@ def postprocessing_results(self,
elif 'border' in img_metas[i]:
pad_key = 'border'
if pad_key is not None:
x_off = img_metas[i][pad_key][2] / scale_factor[1]
y_off = img_metas[i][pad_key][0] / scale_factor[0]
x_off = img_metas[i][pad_key][2] / scale_factor[0]
y_off = img_metas[i][pad_key][0] / scale_factor[1]
bboxes[:, ::2] -= x_off
bboxes[:, 1::2] -= y_off
bboxes *= (bboxes > 0)
Expand Down Expand Up @@ -262,9 +262,9 @@ def postprocessing_results(self,
masks.unsqueeze(0),
size=[
math.ceil(masks.shape[-2] /
img_metas[i]['scale_factor'][0]),
img_metas[i]['scale_factor'][1]),
math.ceil(masks.shape[-1] /
img_metas[i]['scale_factor'][1])
img_metas[i]['scale_factor'][0])
])[..., :ori_h, :ori_w]
masks = masks.squeeze(0)
if masks.dtype != bool:
Expand Down

0 comments on commit 9ccf2f1

Please sign in to comment.