class_docstr: This is the object detection class for using your custom trained models. 
  It supports your custom trained YOLOv3 and TinyYOLOv3 model and allows 
  to you to perform object detection in images.
docstr: Loads image/images from the given path. If the given path is a directory,
  this function only load the images in the directory (it does noot visit the
  subdirectories).
docstr_tok: ["Loads","image\/images","from","the","given","path",".","If","the","given","path","is","a","directory",",","this","function","only","load","the","images","in","the","directory","(","it","does","noot","visit","the","subdirectories",")","."]
code: def __load_image_yolo(
      self, input_image: Union[str, np.ndarray, Image.Image]
  ) -> Tuple[List[str], List[np.ndarray], torch.Tensor, torch.Tensor]:
      """
      Loads image/images from the given path. If the given path is a directory,
      this function only load the images in the directory (it does noot visit the
      subdirectories).
      """
      allowed_exts = ["jpg", "jpeg", "png"]
      fnames = []
      original_dims = []
      inputs = []
      original_imgs = []
      if type(input_image) == str:
          if os.path.isfile(input_image):
              if input_image.rsplit(".")[-1].lower() in allowed_exts:
                  img = cv2.imread(input_image)
          else:
              raise ValueError(
                  f"image path '{input_image}' is not found or a valid file"
              )
      elif type(input_image) == np.ndarray:
          img = input_image
      elif "PIL" in str(type(input_image)):
          img = np.asarray(input_image)
      else:
          raise ValueError(f"Invalid image input format")
  
      img_h, img_w, _ = img.shape
  
      original_imgs.append(
          np.array(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)).astype(
              np.uint8
          )
      )
      original_dims.append((img_w, img_h))
      if type(input_image) == str:
          fnames.append(os.path.basename(input_image))
      else:
          fnames.append("")
      inputs.append(prepare_image(img, (416, 416)))
  
      if original_dims:
          return (
              fnames,
              original_imgs,
              torch.FloatTensor(original_dims)
              .repeat(1, 2)
              .to(self.__device),
              torch.cat(inputs, 0).to(self.__device),
          )
      raise RuntimeError(
          f"Error loading image."
          "\nEnsure the file is a valid image,"
          " allowed file extensions are .jpg, .jpeg, .png"
      )
  
imports: import os
  import time
  import math
  import json
  import warnings
  from typing import List, Union, Tuple, Dict
  from collections import defaultdict
  import numpy
  from PIL import Image
  import cv2
  import torch
  from torch.cuda import amp
  from torch.utils.data import DataLoader
  from torch.optim import SGD, lr_scheduler
  from tqdm import tqdm
  from .yolo.dataset import LoadImagesAndLabels
  from .yolo.custom_anchors import generate_anchors
  from .yolo.compute_loss import compute_loss
  from .yolo import validate
  from ...yolov3.tiny_yolov3 import YoloV3Tiny
  from ...yolov3.yolov3 import YoloV3
  from ...yolov3.utils import draw_bbox_and_label, get_predictions, prepare_image
  from ...backend_check.model_extension import extension_check
label_desc: Use image node_id 7 for calling the CustomObjectDetection obj's underlying member method code with example usage: obj.__load_image_yolo(input_image) and returns: fnames,  original_imgs,  torch,  torch