ai dataset: centre crop the water data to 75% original size

this should both help the model and reduce memory usage
This commit is contained in:
Starbeamrainbowlabs 2022-09-02 18:05:32 +01:00
parent efe41b96ec
commit ad156a9a00
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -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)