class_docstr: This is the image classification class in the ImageAI library. It allows you to classify objects into all the 1000 different classes in the ImageNet dataset [ https://www.kaggle.com/c/imagenet-object-localization-challenge/overview/description ].
  
  The class provides 4 different classification models which are ResNet50, DensesNet121, InceptionV3 and MobileNetV2.
  
  The following functions are required to be called before a classification can be made
  
  * At least of of the following and it must correspond to the model set in the setModelPath()
  [setModelTypeAsMobileNetV2(), setModelTypeAsResNet(), setModelTypeAsDenseNet, setModelTypeAsInceptionV3]
  
  * setModelPath: This is used to specify the absolute path to a pretrained model file. Download any of the files in this release -> https://github.com/OlafenwaMoses/ImageAI/releases/tag/3.0.0-pretrained
  
  * useCPU (Optional): If you will like to force the image classification to be performed on CPU, call this function.
  
  * loadModel: Used to load the pretrained model weights
  
  * classifyImage(): Used for classifying an image.
docstr: 'loadModel()' function is used to load the model weights into the model architecture from the file path defined
  in the setModelPath() function.
  :return:
docstr_tok: ["'loadModel","(",")","'","function","is","used","to","load","the","model","weights","into","the","model","architecture","from","the","file","path","defined","in","the","setModelPath","(",")","function",".",":","return",":"]
code: def loadModel(self):
      """
      'loadModel()' function is used to load the model weights into the model architecture from the file path defined
      in the setModelPath() function.
      :return:
      """
      if not self.__model_loaded:
          try:
              if self.__model_path == None:
                  raise ValueError(
                      "Model path not specified. Call '.setModelPath()' and parse the path to the model file before loading the model."
                  )
  
              if self.__model_type in classification_models.keys():
                  self.__model = classification_models[
                      self.__model_type
                  ]["model"]
              else:
                  raise ValueError(
                      f"Model type '{self.__model_type}' not supported."
                  )
              state_dict = torch.load(self.__model_path)
              if self.__model_type == "densenet121":
                  # '.'s are no longer allowed in module names, but previous densenet layers
                  # as provided by the Pytorch's model zoon has names that uses '.'s.
                  pattern = re.compile(
                      r"^(.*denselayer\d+\.(?:norm|relu|conv))\.((?:[12])\."
                      "(?:weight|bias|running_mean|running_var))$"
                  )
                  for key in list(state_dict.keys()):
                      res = pattern.match(key)
                      if res:
                          new_key = res.group(1) + res.group(2)
                          state_dict[new_key] = state_dict[key]
                          del state_dict[key]
  
              self.__model.load_state_dict(state_dict)
              self.__model.to(self.__device)
              self.__model_loaded = True
              self.__model.eval()
              self.__load_classes()
          except Exception:
              print(traceback.print_exc())
              print(
                  "Weight loading failed.\nEnsure the model path is"
                  " set and the weight file is in the specified model path."
              )
  
imports: import os, re
  from typing import Union
  from typing import List, Tuple
  import numpy
  import torch
  from torchvision.models import resnet50, densenet121, mobilenet_v2, inception_v3
  import torch.nn.functional
  from torchvision import transforms
  from PIL import Image
  import traceback
  from ..backend_check.model_extension import extension_check
label_desc: Use image node_id 10 for calling the ImageClassification obj's underlying member method code with example usage: obj.loadModel() without return types