<filename>videoClassification/preprocessing.py
import tensorflow as tf
import pathlib

def preprocess_image(image):
    image = tf.image.decode_jpeg(image, channels=3)
    image = tf.image.resize(image, [192, 192])
    image /= 255.0  # normalize to [0,1] range
    return image

def load_and_preprocess_image(path):
    image = tf.io.read_file(path)
    return preprocess_image(image)

def caption_image(image_path, data_root):
    image_rel = pathlib.Path(image_path).relative_to(data_root)
    return "Image " + image_rel.parts[-1]

def parse(x):
    result = tf.io.parse_tensor(x, out_type=tf.float32)
    result = tf.reshape(result, [192, 192, 3])
    return result
<filename>videoClassification/preprocessing.py
import tensorflow as tf
import pathlib

def preprocess_image(image):
    image = tf.image.decode_jpeg(image, channels=3)
    image = tf.image.resize(image, [192, 192])
    image /= 255.0  # normalize to [0,1] range
    return image

def load_and_preprocess_image(path):
    image = tf.io.read_file(path)
    return preprocess_image(image)

def caption_image(image_path, data_root):
    image_rel = pathlib.Path(image_path).relative_to(data_root)
    return "Image " + image_rel.parts[-1]

def parse(x):
    result = tf.io.parse_tensor(x, out_type=tf.float32)
    result = tf.reshape(result, [192, 192, 3])
    return result
# normalize to [0,1] range