docstr: batch: (image, polygons, ignore_tags
  batch: a dict produced by dataloaders.
      image: tensor of shape (N, C, H, W).
      polygons: tensor of shape (N, K, 4, 2), the polygons of objective regions.
      ignore_tags: tensor of shape (N, K), indicates whether a region is ignorable or not.
      shape: the original shape of images.
      filename: the original filenames of images.
  pred:
      binary: text region segmentation map, with shape (N, H, W)
      thresh: [if exists] thresh hold prediction with shape (N, H, W)
      thresh_binary: [if exists] binarized with threshhold, (N, H, W)
docstr_tok: ["batch",":","(","image",",","polygons",",","ignore_tags","batch",":","a","dict","produced","by","dataloaders",".","image",":","tensor","of","shape","(","N",",","C",",","H",",","W",")",".","polygons",":","tensor","of","shape","(","N",",","K",",","4",",","2",")",",","the","polygons","of","objective","regions",".","ignore_tags",":","tensor","of","shape","(","N",",","K",")",",","indicates","whether","a","region","is","ignorable","or","not",".","shape",":","the","original","shape","of","images",".","filename",":","the","original","filenames","of","images",".","pred",":","binary",":","text","region","segmentation","map",",","with","shape","(","N",",","H",",","W",")","thresh",":","[","if","exists","]","thresh","hold","prediction","with","shape","(","N",",","H",",","W",")","thresh_binary",":","[","if","exists","]","binarized","with","threshhold",",","(","N",",","H",",","W",")"]
code: def __call__(self, batch, pred, is_output_polygon=False):
      """
      batch: (image, polygons, ignore_tags
      batch: a dict produced by dataloaders.
          image: tensor of shape (N, C, H, W).
          polygons: tensor of shape (N, K, 4, 2), the polygons of objective regions.
          ignore_tags: tensor of shape (N, K), indicates whether a region is ignorable or not.
          shape: the original shape of images.
          filename: the original filenames of images.
      pred:
          binary: text region segmentation map, with shape (N, H, W)
          thresh: [if exists] thresh hold prediction with shape (N, H, W)
          thresh_binary: [if exists] binarized with threshhold, (N, H, W)
      """
      if isinstance(pred, paddle.Tensor):
          pred = pred.numpy()
      pred = pred[:, 0, :, :]
      segmentation = self.binarize(pred)
      boxes_batch = []
      scores_batch = []
      for batch_index in range(pred.shape[0]):
          height, width = batch["shape"][batch_index]
          if is_output_polygon:
              boxes, scores = self.polygons_from_bitmap(
                  pred[batch_index],
                  segmentation[batch_index],
                  width,
                  height,
              )
          else:
              boxes, scores = self.boxes_from_bitmap(
                  pred[batch_index],
                  segmentation[batch_index],
                  width,
                  height,
              )
          boxes_batch.append(boxes)
          scores_batch.append(scores)
      return boxes_batch, scores_batch
  
file_path: PaddleOCR/benchmark/PaddleOCR_DBNet/post_processing/seg_detector_representer.py
imports: import cv2
  import numpy
  import pyclipper
  import paddle
  from shapely.geometry import Polygon
label_desc: Use image node_id 2 for calling the SegDetectorRepresenter obj's underlying member method code with example usage: obj.__call__(batch, pred, is_output_polygon) and returns: boxes_batch,  scores_batch