code: def images_to_tensors(input_files, image_shape, mean_values=None):
      with tf.Graph().as_default():
          image_data = tf.placeholder(tf.string, name="input")
          image_data = tf.image.decode_image(
              image_data, channels=image_shape[2]
          )
          if mean_values:
              image_data = tf.cast(image_data, dtype=tf.float32)
              mean_tensor = tf.constant(
                  mean_values,
                  dtype=tf.float32,
                  shape=[1, 1, image_shape[2]],
              )
              image_data = (image_data - mean_tensor) / 255.0
          else:
              image_data = tf.image.convert_image_dtype(
                  image_data, dtype=tf.float32
              )
              image_data = tf.subtract(image_data, 0.5)
              image_data = tf.multiply(image_data, 2.0)
  
          image_data = tf.expand_dims(image_data, 0)
          image_data = tf.image.resize_bilinear(
              image_data, image_shape[:2], align_corners=False
          )
  
          with tf.Session() as sess:
              for i in range(len(input_files)):
                  with tf.gfile.FastGFile(input_files[i], "rb") as f:
                      src_image = f.read()
                      dst_image = sess.run(
                          image_data, feed_dict={"input:0": src_image}
                      )
                      output_file = os.path.join(
                          FLAGS.output_dir,
                          os.path.splitext(
                              os.path.basename(input_files[i])
                          )[0]
                          + ".dat",
                      )
                      dst_image.tofile(output_file)
  
file_path: mace/tools/image/image_to_tensor.py
imports: import argparse
  import os
  import sys
  import six
  import tensorflow
label_desc: Use image node_id 2 for calling a global function with example usage: images_to_tensors(input_files, image_shape, mean_values) without return types