class_docstr: In debug mode, visualize images according to `gt_box`.
  (Currently only supported when not cropping and flipping image.)
class_docstr_tok: ["In","debug","mode",",","visualize","images","according","to","`","gt_box","`",".","(","Currently","only","supported","when","not","cropping","and","flipping","image",".",")"]
code: def apply(self, sample, context=None):
      image = Image.fromarray(sample["image"].astype(np.uint8))
      out_file_name = "{:012d}.jpg".format(sample["im_id"][0])
      width = sample["w"]
      height = sample["h"]
      # gt_poly = sample['gt_rbox']
      gt_poly = sample["gt_poly"]
      gt_class = sample["gt_class"]
      draw = ImageDraw.Draw(image)
      for i in range(gt_poly.shape[0]):
          x1, y1, x2, y2, x3, y3, x4, y4 = gt_poly[i]
          draw.line(
              [(x1, y1), (x2, y2), (x3, y3), (x4, y4), (x1, y1)],
              width=2,
              fill="green",
          )
          # draw label
          xmin = min(x1, x2, x3, x4)
          ymin = min(y1, y2, y3, y4)
          text = str(gt_class[i][0])
          tw, th = imagedraw_textsize_c(draw, text)
          draw.rectangle(
              [(xmin + 1, ymin - th), (xmin + tw + 1, ymin)],
              fill="green",
          )
          draw.text((xmin + 1, ymin - th), text, fill=(255, 255, 255))
  
      if "gt_keypoint" in sample.keys():
          gt_keypoint = sample["gt_keypoint"]
          if self.is_normalized:
              for i in range(gt_keypoint.shape[1]):
                  if i % 2:
                      gt_keypoint[:, i] = gt_keypoint[:, i] * height
                  else:
                      gt_keypoint[:, i] = gt_keypoint[:, i] * width
          for i in range(gt_keypoint.shape[0]):
              keypoint = gt_keypoint[i]
              for j in range(int(keypoint.shape[0] / 2)):
                  x1 = round(keypoint[2 * j]).astype(np.int32)
                  y1 = round(keypoint[2 * j + 1]).astype(np.int32)
                  draw.ellipse(
                      (x1, y1, x1 + 5, y1 + 5),
                      fill="green",
                      outline="green",
                  )
      save_path = os.path.join(self.output_dir, out_file_name)
      image.save(save_path, quality=95)
      return sample
  
imports: from __future__ import absolute_import
  from __future__ import print_function
  from __future__ import division
  from numbers import Number, Integral
  import cv2
  import numpy
  import math
  import copy
  from .operators import register_op, BaseOperator
  from ppdet.modeling.rbox_utils import poly2rbox_le135_np, poly2rbox_oc_np, rbox2poly_np
  from ppdet.utils.logger import setup_logger
  from ppdet.utils.compact import imagedraw_textsize_c
label_desc: Use image node_id 2 for calling the VisibleRBox obj's underlying member method code with example usage: obj.apply(sample, context) and returns: sample