class_docstr: Decoding predictions of FCENet to instances.
  
  Args:
      fourier_degree (int): The maximum Fourier transform degree k.
      num_reconstr_points (int): The points number of the polygon
          reconstructed from predicted Fourier coefficients.
      rescale_fields (list[str]): The bbox/polygon field names to
          be rescaled. If None, no rescaling will be performed. Defaults to
          ['polygons'].
      scales (list[int]) : The down-sample scale of each layer. Defaults
          to [8, 16, 32].
      text_repr_type (str): Boundary encoding type 'poly' or 'quad'. Defaults
          to 'poly'.
       alpha (float): The parameter to calculate final scores
          :math:`Score_{final} = (Score_{text region} ^ alpha)
          * (Score_{text center_region}^ beta)`. Defaults to 1.0.
      beta (float): The parameter to calculate final score. Defaults to 2.0.
      score_thr (float): The threshold used to filter out the final
          candidates.Defaults to 0.3.
      nms_thr (float): The threshold of nms. Defaults to 0.1.
class_docstr_tok: ["Decoding","predictions","of","FCENet","to","instances",".","Args",":","fourier_degree","(","int",")",":","The","maximum","Fourier","transform","degree","k.","num_reconstr_points","(","int",")",":","The","points","number","of","the","polygon","reconstructed","from","predicted","Fourier","coefficients",".","rescale_fields","(","list","[","str","]",")",":","The","bbox\/polygon","field","names","to","be","rescaled",".","If","None",",","no","rescaling","will","be","performed",".","Defaults","to","[","'polygons","'","]",".","scales","(","list","[","int","]",")",":","The","down-sample","scale","of","each","layer",".","Defaults","to","[","8",",","16",",","32","]",".","text_repr_type","(","str",")",":","Boundary","encoding","type","'poly","'","or","'quad","'",".","Defaults","to","'poly","'",".","alpha","(","float",")",":","The","parameter","to","calculate","final","scores",":","math",":","`","Score_","{","final","}","=","(","Score_","{","text","region","}","^","alpha",")","*","(","Score_","{","text","center_region","}","^","beta",")","`",".","Defaults","to","1.0.","beta","(","float",")",":","The","parameter","to","calculate","final","score",".","Defaults","to","2.0.","score_thr","(","float",")",":","The","threshold","used","to","filter","out","the","final","candidates.Defaults","to","0.3.","nms_thr","(","float",")",":","The","threshold","of","nms",".","Defaults","to","0.1","."]
docstr: Get text instance predictions from one feature level.
  
  Args:
      pred_result (dict): A dict with keys of ``cls_res``, ``reg_res``
          corresponding to the classification result and regression
          result computed from the input tensor with the same index.
          They have the shapes of :math:`(1, C_{cls,i}, H_i, W_i)` and
          :math:`(1, C_{out,i}, H_i, W_i)`.
      scale (int): Scale of current feature map which equals to
          img_size / feat_size.
  
  Returns:
      result_polys (list[ndarray]): A list of polygons after postprocess.
      result_scores (list[ndarray]): A list of scores after postprocess.
docstr_tok: ["Get","text","instance","predictions","from","one","feature","level",".","Args",":","pred_result","(","dict",")",":","A","dict","with","keys","of","``","cls_res","``",",","``","reg_res","``","corresponding","to","the","classification","result","and","regression","result","computed","from","the","input","tensor","with","the","same","index",".","They","have","the","shapes","of",":","math",":","`","(","1",",","C_","{","cls",",","i","}",",","H_i",",","W_i",")","`","and",":","math",":","`","(","1",",","C_","{","out",",","i","}",",","H_i",",","W_i",")","`",".","scale","(","int",")",":","Scale","of","current","feature","map","which","equals","to","img_size","\/","feat_size",".","Returns",":","result_polys","(","list","[","ndarray","]",")",":","A","list","of","polygons","after","postprocess",".","result_scores","(","list","[","ndarray","]",")",":","A","list","of","scores","after","postprocess","."]
code: def _get_text_instances_single(self, pred_result: Dict, scale: int):
      """Get text instance predictions from one feature level.
  
      Args:
          pred_result (dict): A dict with keys of ``cls_res``, ``reg_res``
              corresponding to the classification result and regression
              result computed from the input tensor with the same index.
              They have the shapes of :math:`(1, C_{cls,i}, H_i, W_i)` and
              :math:`(1, C_{out,i}, H_i, W_i)`.
          scale (int): Scale of current feature map which equals to
              img_size / feat_size.
  
      Returns:
          result_polys (list[ndarray]): A list of polygons after postprocess.
          result_scores (list[ndarray]): A list of scores after postprocess.
      """
  
      cls_pred = pred_result["cls_res"]
      tr_pred = cls_pred[0:2].softmax(dim=0).data.cpu().numpy()
      tcl_pred = cls_pred[2:].softmax(dim=0).data.cpu().numpy()
  
      reg_pred = (
          pred_result["reg_res"].permute(1, 2, 0).data.cpu().numpy()
      )
      x_pred = reg_pred[:, :, : 2 * self.fourier_degree + 1]
      y_pred = reg_pred[:, :, 2 * self.fourier_degree + 1 :]
  
      score_pred = (tr_pred[1] ** self.alpha) * (
          tcl_pred[1] ** self.beta
      )
      tr_pred_mask = (score_pred) > self.score_thr
      tr_mask = fill_hole(tr_pred_mask)
  
      tr_contours, _ = cv2.findContours(
          tr_mask.astype(np.uint8),
          cv2.RETR_TREE,
          cv2.CHAIN_APPROX_SIMPLE,
      )  # opencv4
  
      mask = np.zeros_like(tr_mask)
  
      result_polys = []
      result_scores = []
      for cont in tr_contours:
          deal_map = mask.copy().astype(np.int8)
          cv2.drawContours(deal_map, [cont], -1, 1, -1)
  
          score_map = score_pred * deal_map
          score_mask = score_map > 0
          xy_text = np.argwhere(score_mask)
          dxy = xy_text[:, 1] + xy_text[:, 0] * 1j
  
          x, y = x_pred[score_mask], y_pred[score_mask]
          c = x + y * 1j
          c[:, self.fourier_degree] = c[:, self.fourier_degree] + dxy
          c *= scale
  
          polygons = self._fourier2poly(c, self.num_reconstr_points)
          scores = score_map[score_mask].reshape(-1, 1).tolist()
          polygons, scores = self.poly_nms(
              polygons, scores, self.nms_thr
          )
          result_polys += polygons
          result_scores += scores
  
      result_polys, result_scores = self.poly_nms(
          result_polys, result_scores, self.nms_thr
      )
  
      if self.text_repr_type == "quad":
          new_polys = []
          for poly in result_polys:
              poly = np.array(poly).reshape(-1, 2).astype(np.float32)
              points = cv2.boxPoints(cv2.minAreaRect(poly))
              points = np.int0(points)
              new_polys.append(points.reshape(-1))
  
          return new_polys, result_scores
      return result_polys, result_scores
  
file_path: mmocr/mmocr/models/textdet/postprocessors/fce_postprocessor.py
imports: from typing import Dict, List, Sequence
  import cv2
  import numpy
  import torch
  from mmengine.structures import InstanceData
  from numpy.fft import ifft
  from mmocr.registry import MODELS
  from mmocr.structures import TextDetDataSample
  from mmocr.utils import fill_hole
  from .base import BaseTextDetPostProcessor
label_desc: Use image node_id 4 for calling the FCEPostprocessor obj's underlying member method code with example usage: obj._get_text_instances_single(pred_result, scale) and returns: result_polys,  result_scores, new_polys,  result_scores