code: def load_images(input_dir, batch_shape):
      """Read png images from input directory in batches.
  
      Args:
        input_dir: input directory
        batch_shape: shape of minibatch array, i.e. [batch_size, height, width, 3]
  
      Yields:
        filenames: list file names without path of each image
          Lenght of this list could be less than batch_size, in this case only
          first few images of the result are elements of the minibatch.
        images: array with all images from this batch
      """
      images = np.zeros(batch_shape)
      filenames = []
      idx = 0
      batch_size = batch_shape[0]
      for filepath in tf.gfile.Glob(os.path.join(input_dir, "*.png")):
          with tf.gfile.Open(filepath) as f:
              image = imread(f, mode="RGB").astype(np.float) / 255.0
          # Images for inception classifier are normalized to be in [-1, 1] interval.
          images[idx, :, :, :] = image * 2.0 - 1.0
          filenames.append(os.path.basename(filepath))
          idx += 1
          if idx == batch_size:
              yield filenames, images
              filenames = []
              images = np.zeros(batch_shape)
              idx = 0
      if idx > 0:
          yield filenames, images
  
file_path: cleverhans/cleverhans_v3.1.0/examples/nips17_adversarial_competition/dev_toolkit/sample_defenses/adv_inception_v3/defense.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import numpy
  from scipy.misc import imread
  import tensorflow
  from tensorflow.contrib.slim.nets import inception
label_desc: Use image node_id 1 for calling a global function with example usage: load_images(input_dir, batch_shape) without return types