code: def draw_label(draw, coords, label, prob, color, scale=1):
      """Draw a box with the label and probability."""
      # Attempt to get a native TTF font. If not, use the default bitmap font.
      global SYSTEM_FONT
      if SYSTEM_FONT:
          label_font = SYSTEM_FONT.font_variant(
              size=int(round(16 * scale))
          )
          prob_font = SYSTEM_FONT.font_variant(
              size=int(round(12 * scale))
          )
      else:
          label_font = ImageFont.load_default()
          prob_font = ImageFont.load_default()
  
      label = str(label)  # `label` may not be a string.
      prob = "({:.2f})".format(prob)  # Turn `prob` into a string.
  
      # We want the probability font to be smaller, so we'll write the label in
      # two steps.
      label_w, label_h = label_font.getsize(label)
      prob_w, prob_h = prob_font.getsize(prob)
  
      # Get margins to manually adjust the spacing. The margin goes between each
      # segment (i.e. margin, label, margin, prob, margin).
      margin_w, margin_h = label_font.getsize("M")
      margin_w *= 0.2
      _, full_line_height = label_font.getsize("Mq")
  
      # Draw the background first, considering all margins and the full line
      # height.
      background_coords = [
          coords[0],
          coords[1],
          coords[0] + label_w + prob_w + 3 * margin_w,
          coords[1] + full_line_height * 1.15,
      ]
      draw.rectangle(background_coords, fill=color + (255,))
  
      # Then write the two pieces of text.
      draw.text(
          [
              coords[0] + margin_w,
              coords[1],
          ],
          label,
          font=label_font,
      )
  
      draw.text(
          [
              coords[0] + label_w + 2 * margin_w,
              coords[1] + (margin_h - prob_h),
          ],
          prob,
          font=prob_font,
      )
  
file_path: luminoth/luminoth/vis.py
imports: import numpy
  import sys
  from PIL import Image, ImageDraw, ImageFont
label_desc: Use image node_id 5 for calling a global function with example usage: draw_label(draw, coords, label, prob, color, scale) without return types