code: def image_dirs_to_samples(
      directory, resize=None, convert_gray=None, filetypes=None
  ):
      print("Starting to parse images...")
      if filetypes:
          if filetypes not in [list, tuple]:
              filetypes = list(filetypes)
      samples, targets = directory_to_samples(
          directory, flags=filetypes
      )
      for i, s in enumerate(samples):
          samples[i] = load_image(s)
          if resize:
              samples[i] = resize_image(
                  samples[i], resize[0], resize[1]
              )
          if convert_gray:
              samples[i] = convert_color(samples[i], "L")
          samples[i] = pil_to_nparray(samples[i])
          samples[i] /= 255.0
      print("Parsing Done!")
      return samples, targets
  
imports: from __future__ import division, print_function, absolute_import
  import os
  import random
  import numpy
  from PIL import Image
  import pickle
  import csv
  import warnings
  import tensorflow.compat.v1
  from io import BytesIO
label_desc: Use image node_id 15 for calling a global function with example usage: image_dirs_to_samples(directory, resize, convert_gray, filetypes) and returns: samples,  targets