code: def image_model(
      name,
      train_data,
      val_data=None,
      freeze_layers=None,
      metrics=None,
      optimizer_name=U.DEFAULT_OPT,
      multilabel=None,
      pt_fc=[],
      pt_ps=[],
      verbose=1,
  ):
      """
      ```
      Returns a pre-defined/pre-trained model ready to be trained/fine-tuned
      for multi-class classification or regression. By default, all layers are
      trainable/unfrozen.
  
  
      Args:
          name (string): one of model shown on ktrain.vision.print_image_classifiers
          train_data (image.Iterator): train data. Note: Will be manipulated here!
          val_data (image.Iterator): validation data.  Note: Will be manipulated here!
          freeze_layers (int):  number of beginning layers to make untrainable
                              If None, then all layers except new Dense layers
                              will be frozen/untrainable.
          metrics(list): List of metrics to use.  If None: 'accuracy' is used for binar/multiclass,
                         'binary_accuracy' is used for multilabel classification, and 'mae' is used for regression
          optimizer_name(str|obj): name of Keras optimizer (e.g., 'adam', 'sgd') or instance of Keras optimizer
          multilabel(bool):  If True, model will be build to support
                             multilabel classificaiton (labels are not mutually exclusive).
                             If False, binary/multiclassification model will be returned.
                             If None, multilabel status will be inferred from data.
          pt_fc (list of ints): number of hidden units in extra Dense layers
                                  before final Dense layer of pretrained model.
                                  Only takes effect if name in PRETRAINED_MODELS
          pt_ps (list of floats): dropout probabilities to use before
                                  each extra Dense layer in pretrained model.
                                  Only takes effect if name in PRETRAINED_MODELS
          verbose (int):         verbosity
      Return:
          model(Model):  the compiled model ready to be fine-tuned/trained
  
      ```
      """
      # arg check
      U.data_arg_check(train_data=train_data, train_required=True)
      if name not in list(IMAGE_CLASSIFIERS.keys()):
          raise ValueError("Unknown or unsupported model: %s" % (name))
  
      if not U.is_iter(train_data):
          raise ValueError(
              "train_data must be an Keras iterator "
              + "(e.g., DirectoryIterator, DataframIterator, "
              + "NumpyArrayIterator) - please use the ktrain.data.images_from* "
              + "functions"
          )
  
      # check for MobileNetV3
      if (
          name in [PRETRAINED_MOBILENETV3, MOBILENETV3]
          and not HAS_MOBILENETV3
      ):
          raise ValueError(
              f"You chose {name}, but it does not appear to be available in your version of TensorFlow."
          )
  
      # set pretrained flag
      pretrained = True if name in PRETRAINED_MODELS else False
  
      # adjust freeze_layers with warning
      if (
          not pretrained
          and freeze_layers is not None
          and freeze_layers > 0
      ):
          warnings.warn(
              "Only pretrained models (e.g., pretrained_resnet50) support freeze_layers. "
              + "Setting freeze_layers to 0. Use one of the following models if"
              + "desiring a model pretrained on ImageNet: %s"
              % (PRETRAINED_MODELS)
          )
          freeze_layers = 0
  
      if pretrained and val_data is None:
          raise ValueError(
              "val_data is required if selecting a pretrained model, "
              + "as normalization scheme will be altered."
          )
  
      # adjust the data augmentation based on model selected
      if pretrained:
          pretrained_datagen(train_data, name)
          pretrained_datagen(val_data, name)
          U.vprint(
              "The normalization scheme has been changed for use with a %s"
              % (name)
              + " model. If you decide to use a different model, please reload your"
              + " dataset with a ktrain.vision.data.images_from* function.\n",
              verbose=verbose,
          )
  
      # determine if multilabel
      if multilabel is None:
          multilabel = U.is_multilabel(train_data)
      is_regression = False
      if not multilabel and len(train_data[0][-1].shape) == 1:
          is_regression = True
  
      # set metrics
      if is_regression and metrics is None:
          metrics = ["mae"]
      elif multilabel and metrics is None:
          metrics = ["binary_accuracy"]
      elif metrics is None:
          metrics = ["accuracy"]
  
      # set loss and acivations
      loss_func = "categorical_crossentropy"
      activation = "softmax"
      if multilabel:
          loss_func = "binary_crossentropy"
          activation = "sigmoid"
      elif is_regression:
          loss_func = "mse"
          activation = None
  
      U.vprint("Is Multi-Label? %s" % (multilabel), verbose=verbose)
      U.vprint("Is Regression? %s" % (is_regression), verbose=verbose)
  
      # determine number of classes and shape
      num_classes = (
          1 if is_regression else U.nclasses_from_data(train_data)
      )
      input_shape = U.shape_from_data(train_data)
  
      # ------------
      # build model
      # ------------
      model = build_visionmodel(
          name,
          num_classes,
          input_shape=input_shape,
          freeze_layers=freeze_layers,
          activation=activation,
          pt_fc=pt_fc,
          pt_ps=pt_ps,
      )
      model.compile(
          optimizer=optimizer_name, loss=loss_func, metrics=metrics
      )
      return model
  
file_path: ktrain/ktrain/vision/models.py
imports: from ..None import utils
  from ..imports import *
  from .wrn import create_wide_residual_network
label_desc: Use image node_id 6 for calling a global function with example usage: image_model(name, train_data, val_data, freeze_layers, metrics, optimizer_name, multilabel, pt_fc, pt_ps, verbose) and returns: model