class_docstr: Convert transforms's data format from MMOCR to MMDet.
  
  Required Keys:
  
  - img_shape
  - gt_polygons (List[ndarray]) (optional)
  - gt_ignored (np.bool) (optional)
  
  Added Keys:
  
  - gt_masks (PolygonMasks | BitmapMasks) (optional)
  - gt_ignore_flags (np.bool) (optional)
  
  Args:
      poly2mask (bool): Whether to convert mask to bitmap. Default: True.
class_docstr_tok: ["Convert","transforms","'s","data","format","from","MMOCR","to","MMDet",".","Required","Keys",":","-","img_shape","-","gt_polygons","(","List","[","ndarray","]",")","(","optional",")","-","gt_ignored","(","np.bool",")","(","optional",")","Added","Keys",":","-","gt_masks","(","PolygonMasks","|","BitmapMasks",")","(","optional",")","-","gt_ignore_flags","(","np.bool",")","(","optional",")","Args",":","poly2mask","(","bool",")",":","Whether","to","convert","mask","to","bitmap",".","Default",":","True","."]
docstr: Convert MMOCR's data format to MMDet's data format.
  
  Args:
      results (Dict): Result dict containing the data to transform.
  
  Returns:
      (Dict): The transformed data.
docstr_tok: ["Convert","MMOCR","'s","data","format","to","MMDet","'s","data","format",".","Args",":","results","(","Dict",")",":","Result","dict","containing","the","data","to","transform",".","Returns",":","(","Dict",")",":","The","transformed","data","."]
code: def transform(self, results: Dict) -> Dict:
      """Convert MMOCR's data format to MMDet's data format.
  
      Args:
          results (Dict): Result dict containing the data to transform.
  
      Returns:
          (Dict): The transformed data.
      """
      # gt_polygons -> gt_masks
      if "gt_polygons" in results.keys():
          gt_polygons = results.pop("gt_polygons")
          gt_polygons = [[gt_polygon] for gt_polygon in gt_polygons]
          gt_masks = PolygonMasks(gt_polygons, *results["img_shape"])
  
          if self.poly2mask:
              gt_masks = gt_masks.to_bitmap()
  
          results["gt_masks"] = gt_masks
      # gt_ignore_flags -> gt_ignored
      if "gt_ignored" in results.keys():
          gt_ignored = results.pop("gt_ignored")
          results["gt_ignore_flags"] = gt_ignored
  
      return results
  
file_path: mmocr/mmocr/datasets/transforms/adapters.py
imports: from typing import Dict
  from mmcv.transforms.base import BaseTransform
  from mmdet.structures.mask import PolygonMasks, bitmap_to_polygon
  from mmocr.registry import TRANSFORMS
label_desc: Use image node_id 2 for calling the MMOCR2MMDet obj's underlying member method code with example usage: obj.transform(results) and returns: results