From ad156a9a0005ec85618cd0817c74874dde0e3791 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Fri, 2 Sep 2022 18:05:32 +0100 Subject: [PATCH] ai dataset: centre crop the water data to 75% original size this should both help the model and reduce memory usage --- aimodel/src/lib/dataset/dataset.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aimodel/src/lib/dataset/dataset.py b/aimodel/src/lib/dataset/dataset.py index 49575b2..29901c4 100644 --- a/aimodel/src/lib/dataset/dataset.py +++ b/aimodel/src/lib/dataset/dataset.py @@ -28,9 +28,10 @@ def parse_item(metadata): water = tf.reshape(water, tf.constant(metadata["waterdepth"], dtype=tf.int32)) rainfall = tf.transpose(rainfall, [1, 2, 0]) + rainfall = tf.image.resize(rainfall, tf.cast(tf.constant(metadata["waterdepth"]) / 2, dtype=tf.int32)) # [width, height] → [width, height, channels] water = tf.expand_dims(water, axis=-1) - rainfall = tf.image.resize(rainfall, tf.cast(tf.constant(metadata["waterdepth"]) / 2, dtype=tf.int32)) + water = tf.image.central_crop(water, 0.75) # Predict for only the centre 75% of the water data # TODO: The shape of the resulting tensor can't be statically determined, so we need to reshape here print("DEBUG:dataset ITEM rainfall:shape", rainfall.shape, "water:shape", water.shape)