class_docstr: An implementation that allows for easy classification of images
  using the state of the art MobileNet computer vision model.
class_docstr_tok: ["An","implementation","that","allows","for","easy","classification","of","images","using","the","state","of","the","art","MobileNet","computer","vision","model","."]
docstr: Loads image/images from the given path. If image_path is a directory, this
  function only load the images in the directory (it does not visit the sub-
  directories). This function also convert the loaded image/images to the
  specification expected by the MobileNetV2 architecture.
docstr_tok: ["Loads","image\/images","from","the","given","path",".","If","image_path","is","a","directory",",","this","function","only","load","the","images","in","the","directory","(","it","does","not","visit","the","sub-","directories",")",".","This","function","also","convert","the","loaded","image\/images","to","the","specification","expected","by","the","MobileNetV2","architecture","."]
code: def __load_image(
      self, image_path: str
  ) -> Tuple[List[str], torch.Tensor]:
      """
      Loads image/images from the given path. If image_path is a directory, this
      function only load the images in the directory (it does not visit the sub-
      directories). This function also convert the loaded image/images to the
      specification expected by the MobileNetV2 architecture.
      """
      allowed_file_extensions = ["jpg", "jpeg", "png"]
      images = []
      fnames = []
      preprocess = transforms.Compose(
          [
              transforms.Resize(256),
              transforms.CenterCrop(224),
              transforms.ToTensor(),
              transforms.Normalize(
                  mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]
              ),
          ]
      )
      if os.path.isfile(image_path):
          img = Image.open(image_path).convert("RGB")
          images.append(preprocess(img))
          fnames.append(os.path.basename(image_path))
  
      elif os.path.isdir(image_path):
          for file in os.listdir(image_path):
              if (
                  os.path.isfile(os.path.join(image_path, file))
                  and file.rsplit(".")[-1].lower()
                  in allowed_file_extensions
              ):
                  img = Image.open(
                      os.path.join(image_path, file)
                  ).convert("RGB")
                  images.append(preprocess(img))
                  fnames.append(file)
      if images:
          return fnames, torch.stack(images)
      raise RuntimeError(
          f"Error loading images from {os.path.abspath(image_path)}."
          "\nEnsure the folder contains images,"
          " allowed file extensions are .jpg, .jpeg, .png"
      )
  
file_path: ImageAI/imageai/densenet121/__init__.py
imports: import os, warnings
  from pathlib import Path
  from typing import List, Tuple
  import torch, torchvision
  import torch.nn.functional
  from torchvision import transforms
  from PIL import Image
label_desc: Use image node_id 3 for calling the DenseNet121Pretrained obj's underlying member method code with example usage: obj.__load_image(image_path) and returns: fnames,  torch