code: def scan(source_directory, output_directory):
      abs_output_directory = os.path.abspath(output_directory)
      files_and_directories = glob.glob(
          os.path.join(os.path.abspath(source_directory), "*")
      )
  
      directory_count = 0
      directories = []
  
      class_labels = []
  
      for f in files_and_directories:
          if os.path.isdir(f):
              if f != abs_output_directory:
                  directories.append(f)
                  directory_count += 1
  
      directories = sorted(directories)
      label_counter = 0
  
      if directory_count == 0:
          augmentor_images = []
          # This was wrong
          # parent_directory_name = os.path.basename(os.path.abspath(os.path.join(source_directory, os.pardir)))
          parent_directory_name = os.path.basename(
              os.path.abspath(source_directory)
          )
  
          for image_path in scan_directory(source_directory):
              a = AugmentorImage(
                  image_path=image_path,
                  output_directory=abs_output_directory,
              )
              a.class_label = parent_directory_name
              a.class_label_int = label_counter
              a.categorical_label = [label_counter]
              a.file_format = os.path.splitext(image_path)[1].split(
                  "."
              )[1]
              augmentor_images.append(a)
  
          class_labels.append((label_counter, parent_directory_name))
  
          return augmentor_images, class_labels
  
      elif directory_count != 0:
          augmentor_images = []
  
          for d in directories:
              output_directory = os.path.join(
                  abs_output_directory, os.path.split(d)[1]
              )
              for image_path in scan_directory(d):
                  categorical_label = np.zeros(
                      directory_count, dtype=np.uint32
                  )
                  a = AugmentorImage(
                      image_path=image_path,
                      output_directory=output_directory,
                  )
                  a.class_label = os.path.split(d)[1]
                  a.class_label_int = label_counter
                  categorical_label[
                      label_counter
                  ] = 1  # Set to 1 with the index of the current class.
                  a.categorical_label = categorical_label
                  a.file_format = os.path.splitext(image_path)[1].split(
                      "."
                  )[1]
                  augmentor_images.append(a)
              class_labels.append((os.path.split(d)[1], label_counter))
              label_counter += 1
  
          return augmentor_images, class_labels
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  from builtins import *
  import os
  import glob
  import numbers
  import random
  import warnings
  import numpy
label_desc: Use image node_id 3 for calling a global function with example usage: scan(source_directory, output_directory) and returns: augmentor_images,  class_labels, augmentor_images,  class_labels