diff --git a/mmdeploy/codebase/mmdet/models/dense_heads/sparseinst_head.py b/mmdeploy/codebase/mmdet/models/dense_heads/sparseinst_head.py index 6ddbb7744c..8e4c3e487d 100644 --- a/mmdeploy/codebase/mmdet/models/dense_heads/sparseinst_head.py +++ b/mmdeploy/codebase/mmdet/models/dense_heads/sparseinst_head.py @@ -1,11 +1,8 @@ # Copyright (c) OpenMMLab. All rights reserved. -from typing import Dict, List, Tuple +from typing import List import torch import torch.nn.functional as F -from mmdet.models.utils import aligned_bilinear -from mmdet.structures import OptSampleList, SampleList -from mmengine.config import ConfigDict from torch import Tensor from mmdeploy.core import FUNCTION_REWRITER @@ -30,7 +27,7 @@ def sparseinst__predict( max_shape = batch_inputs.shape[-2:] x = self.extract_feat(batch_inputs) output = self.decoder(x) - + pred_scores = output['pred_logits'].sigmoid() pred_masks = output['pred_masks'].sigmoid() pred_objectness = output['pred_scores'].sigmoid() @@ -47,15 +44,13 @@ def sparseinst__predict( img_meta = batch_data_samples[0].metainfo # rescoring mask using maskness - scores = rescoring_mask(scores, - pred_masks > self.mask_threshold, + scores = rescoring_mask(scores, pred_masks > self.mask_threshold, pred_masks) h, w = img_meta['img_shape'][:2] - pred_masks = F.interpolate(pred_masks, - size=max_shape, - mode='bilinear', - align_corners=False)[:, :, :h, :w] - + pred_masks = F.interpolate( + pred_masks, size=max_shape, mode='bilinear', + align_corners=False)[:, :, :h, :w] + bboxes = torch.zeros(scores.shape[0], scores.shape[1], 4) dets = torch.cat([bboxes, scores.unsqueeze(-1)], dim=-1) masks = (pred_masks > self.mask_threshold).float()