code: def images_from_df(
      train_df,
      image_column,
      label_columns=[],
      directory=None,
      val_directory=None,
      suffix="",
      val_df=None,
      is_regression=False,
      target_size=(224, 224),
      color_mode="rgb",
      data_aug=None,
      val_pct=0.1,
      random_state=None,
  ):
      """
      ```
      Returns image generator (Iterator instance).
      Assumes output will be 2D one-hot-encoded labels for categorization.
      Note: This function preprocesses the input in preparation
            for a ResNet50 model.
  
      Args:
      train_df (DataFrame):  pandas dataframe for training dataset
      image_column (string): name of column containing the filenames of images
                             If values in image_column do not have a file extension,
                             the extension should be supplied with suffix argument.
                             If values in image_column are not full file paths,
                             then the path to directory containing images should be supplied
                             as directory argument.
  
      label_columns(list or str): list or str representing the columns that store labels
                                  Labels can be in any one of the following formats:
                                  1. a single column string string (or integer) labels
  
                                     image_fname,label
                                     -----------------
                                     image01,cat
                                     image02,dog
  
                                  2. multiple columns for one-hot-encoded labels
                                     image_fname,cat,dog
                                     image01,1,0
                                     image02,0,1
  
                                  3. a single column of numeric values for image regression
                                     image_fname,age
                                     -----------------
                                     image01,68
                                     image02,18
  
      directory (string): path to directory containing images
                          not required if image_column contains full filepaths
      val_directory(strin): path to directory containing validation images.
                            only required if validation images are in different folder than train images
      suffix(str): will be appended to each entry in image_column
                   Used when the filenames in image_column do not contain file extensions.
                   The extension in suffx should include ".".
      val_df (DataFrame): pandas dataframe for validation set
  
      is_regression(bool): If True, task is treated as regression.
                           Used when there is single column of numeric values and
                           numeric values should be treated as numeric targets as opposed to class labels
      target_size (tuple):  image dimensions
      color_mode (string):  color mode
      data_aug(ImageDataGenerator):  a keras.preprocessing.image.ImageDataGenerator
                                    for data augmentation
      val_pct(float):  proportion of training data to be used for validation
                       only used if val_filepath is None
      random_state(int): random seed for train/test split
  
      Returns:
      batches: a tuple of two Iterators - one for train and one for test
      ```
      """
  
      # read in train and test data
      train_df = train_df.copy()
      if val_df is not None:
          val_df = val_df.copy()
      else:
          train_df, val_df = train_test_split(
              train_df, test_size=val_pct, random_state=random_state
          )
  
      # transform labels
      ytransdf = U.YTransformDataFrame(
          label_columns, is_regression=is_regression
      )
      train_df = ytransdf.apply_train(train_df)
      val_df = ytransdf.apply_test(val_df)
      class_names = ytransdf.get_classes()
      label_columns = ytransdf.get_label_columns(squeeze=True)
  
      # get train and test data generators
      if directory:
          img_folder = directory
      else:
          img_folder = os.path.dirname(train_df[image_column].iloc[0])
      (train_datagen, test_datagen) = process_datagen(
          data_aug,
          train_directory=img_folder,
          target_size=target_size,
          color_mode=color_mode,
          flat_dir=True,
      )
  
      # fix file extensions, if necessary
      if suffix:
          train_df = train_df.copy()
          val_df = val_df.copy()
          train_df[image_column] = train_df.copy()[image_column].apply(
              lambda x: str(x) + suffix
          )
          val_df[image_column] = val_df.copy()[image_column].apply(
              lambda x: str(x) + suffix
          )
  
      # get generators
      batches_tr = train_datagen.flow_from_dataframe(
          train_df,
          directory=directory,
          x_col=image_column,
          y_col=label_columns,
          target_size=target_size,
          class_mode="other",
          shuffle=True,
          interpolation="bicubic",
          color_mode=color_mode,
      )
      batches_te = None
      if val_df is not None:
          d = val_directory if val_directory is not None else directory
          batches_te = test_datagen.flow_from_dataframe(
              val_df,
              directory=d,
              x_col=image_column,
              y_col=label_columns,
              target_size=target_size,
              class_mode="other",
              shuffle=False,
              interpolation="bicubic",
              color_mode=color_mode,
          )
  
      # setup preprocessor
      preproc = ImagePreprocessor(
          test_datagen,
          class_names,
          target_size=target_size,
          color_mode=color_mode,
      )
      return (batches_tr, batches_te, preproc)
  
imports: from ..None import utils
  from ..imports import *
  from .preprocessor import ImagePreprocessor
label_desc: Use image node_id 14 for calling a global function with example usage: images_from_df(train_df, image_column, label_columns, directory, val_directory, suffix, val_df, is_regression, target_size, color_mode, data_aug, val_pct, random_state) and returns: batches_tr,  batches_te,  preproc