import os import time os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2" import tensorflow as tf tf.get_logger().setLevel("ERROR") tf.keras.utils.set_random_seed(2026) AUTOTUNE = tf.data.AUTOTUNE EXAMPLES = 256 BATCH_SIZE = 32 EPOCHS = 3 IMAGE_SHAPE = (128, 128, 3) TARGET_SIZE = (96, 96) source_image = tf.random.uniform( IMAGE_SHAPE, minval=0, maxval=256, dtype=tf.int32, seed=7, ) encoded_image = tf.io.encode_jpeg(tf.cast(source_image, tf.uint8)).numpy() encoded_images = tf.constant([encoded_image] * EXAMPLES) labels = tf.range(EXAMPLES, dtype=tf.int32) % 2 def decode_and_resize(image_bytes, label): image = tf.io.decode_jpeg(image_bytes, channels=3) image = tf.image.resize(image, TARGET_SIZE) image = tf.cast(image, tf.float32) / 255.0 return image, label