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 of one image.
  
  Args:
      pred_results (List[dict]): A list of 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:`(N, C_{cls,i}, H_i,
          W_i)` and :math:`(N, C_{out,i}, H_i, W_i)`.
      data_sample (TextDetDataSample): Datasample of an image.
  
  Returns:
      TextDetDataSample: A new DataSample with predictions filled in.
      Polygons and results are saved in
      ``TextDetDataSample.pred_instances.polygons``. The confidence
      scores are saved in ``TextDetDataSample.pred_instances.scores``.
docstr_tok: ["Get","text","instance","predictions","of","one","image",".","Args",":","pred_results","(","List","[","dict","]",")",":","A","list","of","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",":","`","(","N",",","C_","{","cls",",","i","}",",","H_i",",","W_i",")","`","and",":","math",":","`","(","N",",","C_","{","out",",","i","}",",","H_i",",","W_i",")","`",".","data_sample","(","TextDetDataSample",")",":","Datasample","of","an","image",".","Returns",":","TextDetDataSample",":","A","new","DataSample","with","predictions","filled","in",".","Polygons","and","results","are","saved","in","``","TextDetDataSample.pred_instances.polygons","``",".","The","confidence","scores","are","saved","in","``","TextDetDataSample.pred_instances.scores","``","."]
code: def get_text_instances(
      self, pred_results: Sequence[Dict], data_sample: TextDetDataSample
  ) -> TextDetDataSample:
      """Get text instance predictions of one image.
  
      Args:
          pred_results (List[dict]): A list of 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:`(N, C_{cls,i}, H_i,
              W_i)` and :math:`(N, C_{out,i}, H_i, W_i)`.
          data_sample (TextDetDataSample): Datasample of an image.
  
      Returns:
          TextDetDataSample: A new DataSample with predictions filled in.
          Polygons and results are saved in
          ``TextDetDataSample.pred_instances.polygons``. The confidence
          scores are saved in ``TextDetDataSample.pred_instances.scores``.
      """
      assert len(pred_results) == len(self.scales)
      data_sample.pred_instances = InstanceData()
      data_sample.pred_instances.polygons = []
      data_sample.pred_instances.scores = []
  
      result_polys = []
      result_scores = []
      for idx, pred_result in enumerate(pred_results):
          # TODO: Scale can be calculated given image shape and feature
          # shape. This param can be removed in the future.
          polygons, scores = self._get_text_instances_single(
              pred_result, self.scales[idx]
          )
          result_polys += polygons
          result_scores += scores
      result_polys, result_scores = self.poly_nms(
          result_polys, result_scores, self.nms_thr
      )
      for result_poly, result_score in zip(result_polys, result_scores):
          result_poly = np.array(result_poly, dtype=np.float32)
          data_sample.pred_instances.polygons.append(result_poly)
          data_sample.pred_instances.scores.append(result_score)
      data_sample.pred_instances.scores = torch.FloatTensor(
          data_sample.pred_instances.scores
      )
  
      return data_sample
  
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 3 for calling the FCEPostprocessor obj's underlying member method code with example usage: obj.get_text_instances(pred_results, data_sample) and returns: data_sample