def METHOD_NAME(self, data: MMDET_SampleList,
                      data_samples: DetSampleList) -> DetSampleList:
    """Convert Instance datas from MMDet into MMOCR's format.
    Args:
        data: (list[DetDataSample]): Detection results of the
            input images. Each DetDataSample usually contain
            'pred_instances'. And the ``pred_instances`` usually
            contains following keys.
            - scores (Tensor): Classification scores, has a shape
                (num_instance, )
            - labels (Tensor): Labels of bboxes, has a shape
                (num_instances, ).
            - bboxes (Tensor): Has a shape (num_instances, 4),
                the last dimension 4 arrange as (x1, y1, x2, y2).
            - masks (Tensor, Optional): Has a shape (num_instances, H, W).
        data_samples (list[:obj:`TextDetDataSample`]): The annotation data
            of every samples.
    Returns:
        list[TextDetDataSample]: A list of N datasamples containing ground
            truth and prediction results.
            The polygon results are saved in
            ``TextDetDataSample.pred_instances.polygons``
            The confidence scores are saved in
            ``TextDetDataSample.pred_instances.scores``.
    """
    for i, det_data_sample in enumerate(data):
        data_samples[i].pred_instances = InstanceData()
        # convert mask to polygons if mask exists
        if 'masks' in det_data_sample.pred_instances.keys():
            masks = det_data_sample.pred_instances.masks.cpu().numpy()
            polygons = []
            scores = []
            for mask_idx, mask in enumerate(masks):
                contours, _ = bitmap_to_polygon(mask)
                polygons += [contour.reshape(-1) for contour in contours]
                scores += [
                    det_data_sample.pred_instances.scores[mask_idx].cpu()
                ] * len(contours)
            # filter invalid polygons
            filterd_polygons = []
            keep_idx = []
            for poly_idx, polygon in enumerate(polygons):
                if len(polygon) < 6:
                    continue
                filterd_polygons.append(polygon)
                keep_idx.append(poly_idx)
            # convert by text_repr_type
            if self.text_repr_type == 'quad':
                for j, poly in enumerate(filterd_polygons):
                    poly = poly.reshape(-1, 2)
                    rect = cv2.minAreaRect(poly)
                    vertices = cv2.boxPoints(rect)
                    poly = vertices.flatten()
                    filterd_polygons[j] = poly
            data_samples[i].pred_instances.polygons = filterd_polygons
            data_samples[i].pred_instances.scores = torch.FloatTensor(
                scores)[keep_idx]
        else:
            bboxes = det_data_sample.pred_instances.bboxes.cpu().numpy()
            polygons = [bbox2poly(bbox) for bbox in bboxes]
            data_samples[i].pred_instances.polygons = polygons
            data_samples[i].pred_instances.scores = torch.FloatTensor(
                det_data_sample.pred_instances.scores.cpu())
    return data_samples