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: Classfies image/images according to the classes provided by imagenet.
  
  Parameters:
  -----------
      image_path: a path to a single image or a path to a directory containing
                  images. If image_path is a path to a file, this functions
                  classifies the image according to the categories provided
                  by imagenet, else, if image_path is a path to a directory
                  that contains images, this function classifies all images in
                  the given directory (it doesn't visit the subdirectories).
  
      top_n: number of top predictions to return.
      verbose: if true, it prints the top_n predictions.
docstr_tok: ["Classfies","image\/images","according","to","the","classes","provided","by","imagenet",".","Parameters",":","--","--","--","--","--","-","image_path",":","a","path","to","a","single","image","or","a","path","to","a","directory","containing","images",".","If","image_path","is","a","path","to","a","file",",","this","functions","classifies","the","image","according","to","the","categories","provided","by","imagenet",",","else",",","if","image_path","is","a","path","to","a","directory","that","contains","images",",","this","function","classifies","all","images","in","the","given","directory","(","it","does","n't","visit","the","subdirectories",")",".","top_n",":","number","of","top","predictions","to","return",".","verbose",":","if","true",",","it","prints","the","top_n","predictions","."]
code: def classify(
      self, image_path: str, top_n: int = 5, verbose: bool = True
  ) -> List[List[Tuple[str, str]]]:
      """
      Classfies image/images according to the classes provided by imagenet.
  
      Parameters:
      -----------
          image_path: a path to a single image or a path to a directory containing
                      images. If image_path is a path to a file, this functions
                      classifies the image according to the categories provided
                      by imagenet, else, if image_path is a path to a directory
                      that contains images, this function classifies all images in
                      the given directory (it doesn't visit the subdirectories).
  
          top_n: number of top predictions to return.
          verbose: if true, it prints the top_n predictions.
      """
      if not self.__has_loaded_weights:
          if self.__model_path:
              warnings.warn(
                  "Model path has changed but pretrained weights in the"
                  " new path are yet to be loaded.",
                  ResourceWarning,
              )
          else:
              warnings.warn(
                  "Model path isn't set, pretrained weights aren't used.",
                  ResourceWarning,
              )
  
      fnames, images = self.__load_image(image_path)
      images = images.to(self.__device)
      print(images.shape)
  
      with torch.no_grad():
          output = self.__model(images)
      probabilities = torch.softmax(output, dim=1)
      top5_prob, top5_catid = torch.topk(probabilities, 5)
  
      with open(
          os.path.join(
              str(Path(__file__).resolve().parent.parent),
              "imagenet_classes.txt",
          )
      ) as f:
          categories = [c.strip() for c in f.readlines()]
      predictions = [
          [
              (
                  categories[top5_catid[i][j]],
                  f"{top5_prob[i][j].item()*100:.5f}%",
              )
              for j in range(top5_prob.shape[1])
          ]
          for i in range(top5_prob.shape[0])
      ]
  
      if verbose:
          for idx, pred in enumerate(predictions):
              print(
                  "-" * 50,
                  f"Top 5 predictions for {fnames[idx]}",
                  "-" * 50,
                  sep="\n",
              )
              for label, score in pred:
                  print(f"\t{label}:{score: >10}")
              print("-" * 50, "\n")
      return predictions
  
file_path: ImageAI/imageai/inceptionv3/__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 6 for calling the InceptionV3Pretrained obj's underlying member method code with example usage: obj.classify(image_path, top_n, verbose) and returns: predictions