import os os.environ.setdefault("TF_CPP_MIN_LOG_LEVEL", "2") os.environ.setdefault("TF_NUM_INTRAOP_THREADS", "6") os.environ.setdefault("TF_NUM_INTEROP_THREADS", "2") import numpy as np from PIL import Image, ImageOps CLASSES = ["Forest", "River", "Residential", "Agriculture", "Industrial"] SOURCE_CLASSES = ["Forest", "River", "Residential", "AnnualCrop", "Industrial"] SIZE = 64 def preprocess(image): """Return RGB float32 pixels in [0,255]; the model contains normalization.""" image = ImageOps.exif_transpose(image).convert("RGB") return np.asarray( image.resize((SIZE, SIZE), Image.Resampling.BILINEAR), dtype=np.float32 ) def configure(seed=42): import tensorflow as tf tf.keras.utils.set_random_seed(seed) tf.config.experimental.enable_op_determinism() return { "devices": [str(d) for d in tf.config.list_physical_devices()], "deterministic_ops": True, }