docstr: img: an RGB image of shape (H, W, 3).
docstr_tok: ["img",":","an","RGB","image","of","shape","(","H",",","W",",","3",")","."]
code: def __init__(
      self,
      img,
      scale=1.2,
      edgecolor="g",
      alpha=0.5,
      linestyle="-",
      saveas="test_out.jpg",
      rgb=True,
      pynb=False,
      id2obj=None,
      id2attr=None,
      pad=0.7,
  ):
      """
      img: an RGB image of shape (H, W, 3).
      """
      if isinstance(img, torch.Tensor):
          img = img.numpy().astype("np.uint8")
      if isinstance(img, str):
          img = img_tensorize(img)
      assert isinstance(img, np.ndarray)
  
      width, height = img.shape[1], img.shape[0]
      fig = mplfigure.Figure(frameon=False)
      dpi = fig.get_dpi()
      width_in = (width * scale + 1e-2) / dpi
      height_in = (height * scale + 1e-2) / dpi
      fig.set_size_inches(width_in, height_in)
      ax = fig.add_axes([0.0, 0.0, 1.0, 1.0])
      ax.axis("off")
      ax.set_xlim(0.0, width)
      ax.set_ylim(height)
  
      self.saveas = saveas
      self.rgb = rgb
      self.pynb = pynb
      self.img = img
      self.edgecolor = edgecolor
      self.alpha = 0.5
      self.linestyle = linestyle
      self.font_size = int(np.sqrt(min(height, width)) * scale // 3)
      self.width = width
      self.height = height
      self.scale = scale
      self.fig = fig
      self.ax = ax
      self.pad = pad
      self.id2obj = id2obj
      self.id2attr = id2attr
      self.canvas = FigureCanvasAgg(fig)
  
imports: import colorsys
  import io
  import matplotlib
  import matplotlib.colors
  import matplotlib.figure
  import numpy
  import torch
  from matplotlib.backends.backend_agg import FigureCanvasAgg
  import cv2
  from utils import img_tensorize
label_desc: Use image node_id 1 to create a new SingleImageViz object  with example: obj = SingleImageViz(img, scale, edgecolor, alpha, linestyle, saveas, rgb, pynb, id2obj, id2attr, pad)