code: def _end2end_detect(
      img: Union[PIL.Image.Image, np.ndarray, Path, str],
      transforms: albumentations_adapter.Adapter,
      model: torch.nn.Module,
      class_map: ClassMap,
      detection_threshold: float = 0.5,
      predict_fn: Callable = None,
      display_label: bool = True,
      display_bbox: bool = True,
      display_score: bool = True,
      font_path: Optional[os.PathLike] = DEFAULT_FONT_PATH,
      font_size: Union[int, float] = 12,
      label_color: Union[np.array, list, tuple, str] = (
          "#FF59D6"
      ),  # Pink
      return_as_pil_img=True,
      return_img=True,
      **kwargs,
  ):
      """
      Run Object Detection inference (only `bboxes`) on a single image.
  
      Parameters
      ----------
      img: image to run inference on. It can be a string, Path or PIL.Image or numpy
      transforms: icevision albumentations transforms
      model: model to run inference with
      class_map: ClassMap with the available categories
      detection_threshold: confidence threshold below which bounding boxes are discarded
      display_label: display or not a bounding box label(i.e class)
      display_bbox: display or not a bounding box
      display_score: display or not a bounding box score
      font_path: path to the font file used
      font_size: font size
      label_color: a <collection> of RGB values or a hex code string that defines
                     the color of all the plotted labels
      return_as_pil_img: if True a PIL image is returned otherwise a numpy array is returned
      return_img: whether we should also return an image in addition to the bounding boxes, labels, and scores
  
      Returns
      -------
      A dictionnary with categories, scores, bounding box coordinates, image height and width,
                     and optionally a PIL Image or a numpy array (image).
                     Bounding boxes are adjusted to the original image size and aspect ratio
      """
      if isinstance(img, (str, Path)):
          img = open_img(str(img), ensure_no_data_convert=True)
  
      infer_ds = Dataset.from_images(
          [np.array(img)], transforms, class_map=class_map
      )
      pred = predict_fn(
          model, infer_ds, detection_threshold=detection_threshold
      )[0]
      pred = process_bbox_predictions(pred, img, transforms.tfms_list)
      record = pred.pred
  
      # draw image, return it as PIL image by default otherwise as numpy array
      if return_img:
          pred_img = draw_record(
              record=pred,
              class_map=class_map,
              display_label=display_label,
              display_score=display_score,
              display_bbox=display_bbox,
              font_path=font_path,
              font_size=font_size,
              label_color=label_color,
              return_as_pil_img=return_as_pil_img,
              **kwargs,
          )
          record.set_img(pred_img)
      else:
          record._unload()
  
      img_size = get_img_size_from_data(img)
      record.set_img_size(img_size)
  
      pred_dict = record.as_dict()
  
      # expose img at the root instead of having under the `common` key
      if return_img:
          pred_dict["img"] = pred_img
      else:
          pred_dict["img"] = None
  
      pred_dict["width"] = img_size.width
      pred_dict["height"] = img_size.height
      # delete the `common` key that holds both the `img` and its shape
      del pred_dict["common"]
  
      # return a dict that contains the image with its predicted boxes (i.e. with resized boxes that match the original image size)
      # labels, and prediction scores
      return pred_dict
  
file_path: icevision/icevision/models/inference.py
imports: from icevision.imports import *
  from icevision.core import *
  from icevision.data import *
  from icevision.tfms.albumentations.albumentations_helpers import get_size_without_padding
  from icevision.tfms.albumentations import albumentations_adapter
  from icevision.utils.imageio import *
  from icevision.visualize.draw_data import *
  from icevision.visualize.utils import *
  from icevision.utils.imageio import get_img_size_from_data
label_desc: Use image node_id 1 for calling a global function with example usage: _end2end_detect(img, transforms, model, class_map, detection_threshold, predict_fn, display_label, display_bbox, display_score, font_path, font_size, label_color, return_as_pil_img, return_img) and returns: pred_dict