code: def plot_detections(
      image,
      tlwhs,
      obj_ids,
      idx2classname,
      conf_threshold,
      scores=None,
      text_scale=0.75,
      text_thickness=1,
      line_thickness=2,
      alpha=0.5,
  ):
      """
      Plot the detections on to the corresponding image
  
      Parameters
      ----------
      image
          np.ndarray: np array containing the image data
      tlwhs
          list: list containing the bounding boxes in (x1, y1, x2, y2) format
      obj_ids
          list: list containing the class indices of the bounding boxes, length should match tlwhs
      idx2classname
          dict: maps obj_ids to class name (str)
      conf_threshold
          float: confidence threshold to filter bounding boxes
      scores
          list: confidence scores of the bounding boxes, length should match tlwhs
      text_scale
          float: font size of the text display
      text_thickness
          int: font weight of the text display
      line_thickness
          int: line width of the bounding box display
      alpha
          float: opacity of the text display background color
  
      Returns
      -------
      an np.ndarray of visualized image
      """
      # TODO: Convert to use mmdet package
      try:
          import cv2
      except:
          raise ImportError(
              "No module named: cv2. Please install cv2 by 'pip install opencv-python'"
          )
      im = np.ascontiguousarray(np.copy(image))
      im_h, im_w = im.shape[:2]
  
      font = cv2.FONT_HERSHEY_DUPLEX
      text_scale = text_scale if im_w > 500 else text_scale * 0.8
  
      title = "num_det: %d conf: %.2f" % (len(tlwhs), conf_threshold)
      im = add_text_with_bg_color(
          im=im,
          text=title,
          tl=(0, 0),
          bg_color=(0, 0, 0),
          alpha=alpha,
          font=font,
          text_scale=text_scale,
          text_thickness=text_thickness,
      )
  
      for i, tlwh in enumerate(tlwhs):
          x1, y1, w, h = tlwh
          intbox = tuple(map(int, (x1, y1, x1 + w, y1 + h)))
          obj_id = int(obj_ids[i])
          id_text = idx2classname[obj_ids[i]]
          if scores is not None:
              id_text = id_text + ",{:.3f}".format(float(scores[i]))
          color = get_color(abs(obj_id))
          im = add_bbox_with_alpha(
              im=im,
              tl=intbox[0:2],
              br=intbox[2:4],
              line_color=color,
              alpha=alpha,
              line_thickness=line_thickness,
          )
          im = add_text_with_bg_color(
              im=im,
              text=id_text,
              tl=(intbox[0], intbox[1]),
              bg_color=color,
              alpha=0.75,
              font=font,
              text_scale=text_scale,
              text_thickness=text_thickness,
          )
      return im
  
imports: import json
  import logging
  import os
  import warnings
  from pathlib import Path
  from typing import Dict, Iterable, List, Optional, Union
  import defusedxml.ElementTree
  import numpy
  import pandas
  import PIL
  from torchmetrics.detection.mean_ap import MeanAveragePrecision
  from ..constants import BBOX, LABEL, MAP, MAP_50, MAP_75, MAP_LARGE, MAP_MEDIUM, MAP_SMALL, MAR_1, MAR_10, MAR_100, MAR_LARGE, MAR_MEDIUM, MAR_SMALL, MEAN_AVERAGE_PRECISION
  from .download import download, is_url
label_desc: Use image node_id 31 for calling a global function with example usage: plot_detections(image, tlwhs, obj_ids, idx2classname, conf_threshold, scores, text_scale, text_thickness, line_thickness, alpha) and returns: im