當前位置: 首頁>>代碼示例>>Python>>正文


Python core.bbox2result方法代碼示例

本文整理匯總了Python中mmdet.core.bbox2result方法的典型用法代碼示例。如果您正苦於以下問題:Python core.bbox2result方法的具體用法?Python core.bbox2result怎麽用?Python core.bbox2result使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mmdet.core的用法示例。


在下文中一共展示了core.bbox2result方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: async_simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def async_simple_test(self,
                                x,
                                proposal_list,
                                img_metas,
                                proposals=None,
                                rescale=False):
        """Async test without augmentation."""
        assert self.with_bbox, 'Bbox head must be implemented.'

        det_bboxes, det_labels = await self.async_test_bboxes(
            x, img_metas, proposal_list, self.test_cfg, rescale=rescale)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)
        if not self.with_mask:
            return bbox_results
        else:
            segm_results = await self.async_test_mask(
                x,
                img_metas,
                det_bboxes,
                det_labels,
                rescale=rescale,
                mask_test_cfg=self.test_cfg.get('mask'))
            return bbox_results, segm_results 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:26,代碼來源:standard_roi_head.py

示例2: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self,
                    x,
                    proposal_list,
                    img_metas,
                    proposals=None,
                    rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, 'Bbox head must be implemented.'

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_metas, proposal_list, self.test_cfg, rescale=rescale)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            segm_results = self.simple_test_mask(
                x, img_metas, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:22,代碼來源:standard_roi_head.py

示例3: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."

        x = self.extract_feat(img)

        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            segm_results = self.simple_test_mask(
                x, img_meta, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:22,代碼來源:two_stage.py

示例4: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."

        x = self.extract_feat(img)

        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        det_bboxes, det_labels = self.simple_test_bboxes_hkrm(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale, use_hkrm=True)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head_hkrm.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            segm_results = self.simple_test_mask(
                x, img_meta, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:chanyn,項目名稱:Reasoning-RCNN,代碼行數:22,代碼來源:hkrm_rcnn.py

示例5: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."
        if self.use_consistent_supervision:
            x, y = self.extract_feat(img)
        else:
            x = self.extract_feat(img)

        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            segm_results = self.simple_test_mask(
                x, img_meta, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:Gus-Guo,項目名稱:AugFPN,代碼行數:24,代碼來源:two_stage.py

示例6: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self,
                    x,
                    proposal_list,
                    img_metas,
                    proposals=None,
                    rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, 'Bbox head must be implemented.'

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_metas, proposal_list, self.test_cfg, rescale=False)
        # pack rois into bboxes
        grid_rois = bbox2roi([det_bboxes[:, :4]])
        grid_feats = self.grid_roi_extractor(
            x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois)
        if grid_rois.shape[0] != 0:
            self.grid_head.test_mode = True
            grid_pred = self.grid_head(grid_feats)
            det_bboxes = self.grid_head.get_bboxes(det_bboxes,
                                                   grid_pred['fused'],
                                                   img_metas)
            if rescale:
                scale_factor = img_metas[0]['scale_factor']
                if not isinstance(scale_factor, (float, torch.Tensor)):
                    scale_factor = det_bboxes.new_tensor(scale_factor)
                det_bboxes[:, :4] /= scale_factor
        else:
            det_bboxes = torch.Tensor([])

        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            segm_results = self.simple_test_mask(
                x, img_metas, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:40,代碼來源:grid_roi_head.py

示例7: aug_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def aug_test(self, x, proposal_list, img_metas, rescale=False):
        """Test with augmentations.

        If rescale is False, then returned bboxes and masks will fit the scale
        of imgs[0].
        """
        # recompute feats to save memory
        det_bboxes, det_labels = self.aug_test_bboxes(x, img_metas,
                                                      proposal_list,
                                                      self.test_cfg)

        if rescale:
            _det_bboxes = det_bboxes
        else:
            _det_bboxes = det_bboxes.clone()
            _det_bboxes[:, :4] *= det_bboxes.new_tensor(
                img_metas[0][0]['scale_factor'])
        bbox_results = bbox2result(_det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        # det_bboxes always keep the original scale
        if self.with_mask:
            segm_results = self.aug_test_mask(x, img_metas, det_bboxes,
                                              det_labels)
            return bbox_results, segm_results
        else:
            return bbox_results 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:29,代碼來源:standard_roi_head.py

示例8: aug_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def aug_test(self, imgs, img_metas, rescale=False):
        """Test with augmentations.

        If rescale is False, then returned bboxes and masks will fit the scale
        of imgs[0].
        """
        # recompute feats to save memory
        proposal_list = self.aug_test_rpn(
            self.extract_feats(imgs), img_metas, self.test_cfg.rpn)
        det_bboxes, det_labels = self.aug_test_bboxes(
            self.extract_feats(imgs), img_metas, proposal_list,
            self.test_cfg.rcnn)

        if rescale:
            _det_bboxes = det_bboxes
        else:
            _det_bboxes = det_bboxes.clone()
            _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor']
        bbox_results = bbox2result(_det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        # det_bboxes always keep the original scale
        if self.with_mask:
            segm_results = self.aug_test_mask(
                self.extract_feats(imgs), img_metas, det_bboxes, det_labels)
            return bbox_results, segm_results
        else:
            return bbox_results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:30,代碼來源:two_stage.py

示例9: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."
        assert self.with_rbbox, "RBox head must be implemented."
        x = self.extract_feat(img)

        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
        # TODO: implement the dbbox2result
        # bbox_results = dbbox2result(det_bboxes, det_labels,
        #                            self.bbox_head.num_classes)
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_rbbox:
            return bbox_results
        else:
            det_rbboxes, det_rlabels = self.simple_test_rbboxes_v2(
                x, img_meta, det_bboxes, self.test_cfg.rrcnn, rescale=rescale)
            # import pdb
            # pdb.set_trace()
            rbbox_results = dbbox2result(det_rbboxes, det_rlabels,
                                         self.rbbox_head.num_classes)
            return bbox_results, rbbox_results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:29,代碼來源:faster_rcnn_hbb_obb.py

示例10: aug_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def aug_test(self, imgs, img_metas, rescale=False):
        """Test with augmentations.

        If rescale is False, then returned bboxes and masks will fit the scale
        of imgs[0].
        """
        # recompute feats to save memory
        assert NotImplementedError
        # proposal_list = self.aug_test_rpn(
        #     self.extract_feats(imgs), img_metas, self.test_cfg.rpn)
        # det_bboxes, det_labels = self.aug_test_bboxes(
        #     self.extract_feats(imgs), img_metas, proposal_list,
        #     self.test_cfg.rcnn)
        #
        # if rescale:
        #     _det_bboxes = det_bboxes
        # else:
        #     _det_bboxes = det_bboxes.clone()
        #     _det_bboxes[:, :4] *= img_metas[0][0]['scale_factor']
        # bbox_results = bbox2result(_det_bboxes, det_labels,
        #                            self.bbox_head.num_classes)

        # det_bboxes always keep the original scale
        # if self.with_mask:
        #     segm_results = self.aug_test_mask(
        #         self.extract_feats(imgs), img_metas, det_bboxes, det_labels)
        #     return bbox_results, segm_results
        # else:
        #     return bbox_results 
開發者ID:dingjiansw101,項目名稱:AerialDetection,代碼行數:31,代碼來源:faster_rcnn_hbb_obb.py

示例11: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."

        x = self.extract_feat(img)

        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=False)

        # pack rois into bboxes
        grid_rois = bbox2roi([det_bboxes[:, :4]])
        grid_feats = self.grid_roi_extractor(
            x[:len(self.grid_roi_extractor.featmap_strides)], grid_rois)
        if grid_rois.shape[0] != 0:
            self.grid_head.test_mode = True
            grid_pred = self.grid_head(grid_feats)
            det_bboxes = self.grid_head.get_bboxes(det_bboxes,
                                                   grid_pred['fused'],
                                                   img_meta)
            if rescale:
                det_bboxes[:, :4] /= img_meta[0]['scale_factor']
        else:
            det_bboxes = torch.Tensor([])

        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        return bbox_results 
開發者ID:xvjiarui,項目名稱:GCNet,代碼行數:33,代碼來源:grid_rcnn.py

示例12: simple_test

# 需要導入模塊: from mmdet import core [as 別名]
# 或者: from mmdet.core import bbox2result [as 別名]
def simple_test(self, img, img_meta, proposals=None, rescale=False):
        """Test without augmentation."""
        assert self.with_bbox, "Bbox head must be implemented."

        # 經過backbone和FPN特征提取層,得到若幹個輸出特征圖組成tuple
        x = self.extract_feat(img)

        # 定義在RPNTestMixin中,用於生成RPN輸出後處理得到的proposals(真實坐標)(NMS過)
        # 注意list的長度對應的是圖片的數目
        #輸入特征圖,生成anchors,分類回歸,NMS,坐標還原,生成proposals
        proposal_list = self.simple_test_rpn(
            x, img_meta, self.test_cfg.rpn) if proposals is None else proposals

        # 定義在BBoxTestMixin中
        # 輸入proposals,進行RoI池化,分類回歸,NMS,得到真正的檢測目標和坐標的坐標偏移
        det_bboxes, det_labels = self.simple_test_bboxes(
            x, img_meta, proposal_list, self.test_cfg.rcnn, rescale=rescale)
        # 偏移還原為真實坐坐標
        bbox_results = bbox2result(det_bboxes, det_labels,
                                   self.bbox_head.num_classes)

        if not self.with_mask:
            return bbox_results
        else:
            # 分割任務加mask
            segm_results = self.simple_test_mask(
                x, img_meta, det_bboxes, det_labels, rescale=rescale)
            return bbox_results, segm_results 
開發者ID:ming71,項目名稱:mmdetection-annotated,代碼行數:30,代碼來源:two_stage.py


注:本文中的mmdet.core.bbox2result方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。