code: def process_data(dataset_root, classes):
      # Load class names
      with open(classes, "r", encoding="utf-8") as f:
          classes = f.readlines()
          classes = list(map(lambda x: x.strip(), classes))
  
      # Make input_paths and labels
      input_paths, labels = [], []
      for class_name in os.listdir(dataset_root):
          class_root = os.path.join(dataset_root, class_name)
          class_id = classes.index(class_name)
          for path in os.listdir(class_root):
              path = os.path.join(class_root, path)
              if imghdr.what(path) is None:
                  # this is not an image file
                  continue
              input_paths.append(path)
              labels.append(class_id)
  
      # Convert to numpy array
      input_paths = np.array(input_paths)
      labels = np.array(labels, dtype=np.int32)
  
      # Shuffle dataset
      np.random.seed(0)
      perm = np.random.permutation(len(input_paths))
      input_paths = input_paths[perm]
      labels = labels[perm]
  
      # Split dataset for training and validation
      border = int(len(input_paths) * 0.8)
      train_labels = labels[:border]
      val_labels = labels[border:]
      train_input_paths = input_paths[:border]
      val_input_paths = input_paths[border:]
  
      print(
          "Training on %d images and labels" % (len(train_input_paths))
      )
      print(
          "Validation on %d images and labels" % (len(val_input_paths))
      )
  
      return (
          train_input_paths,
          train_labels,
          val_input_paths,
          val_labels,
      )
  
imports: import os
  import imghdr
  import numpy
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: process_data(dataset_root, classes) and returns: train_input_paths,  train_labels,  val_input_paths,  val_labels