ai: how did things get this confusing

This commit is contained in:
Starbeamrainbowlabs 2022-09-02 18:51:46 +01:00
parent 1c5defdcd6
commit 1d1533d160
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 3 additions and 4 deletions

View file

@ -14,7 +14,7 @@ def model_rainfallwater_contrastive(metadata, shape_water, batch_size=64, featur
water_width, water_height = shape_water # shape = [width, height]
water_channels = 1 # added in dataset → make_dataset → parse_item
rainfall_width, rainfall_height = math.floor(rainfall_width / 2), math.floor(rainfall_height / 2)
# rainfall_width, rainfall_height = math.floor(rainfall_width / 2), math.floor(rainfall_height / 2)
logger.info("SOURCE shape_rainfall " + str(metadata["rainfallradar"]))
logger.info("SOURCE shape_water " + str(metadata["waterdepth"]))

View file

@ -31,13 +31,12 @@ def parse_item(metadata, shape_water_desired):
rainfall = tf.reshape(rainfall, tf.constant(metadata["rainfallradar"], dtype=tf.int32))
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))
rainfall = tf.transpose(rainfall, [1, 2, 0]) # channels_first → channels_last
# rainfall = tf.image.resize(rainfall, tf.cast(tf.constant(metadata["rainfallradar"]) / 2, dtype=tf.int32))
water = tf.expand_dims(water, axis=-1) # [width, height] → [width, height, channels]
water = tf.image.crop_to_bounding_box(water, water_offset_x, water_offset_y, water_width_target, water_height_target)
# 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)
# TODO: Any other additional parsing here, since multiple .map() calls are not optimal
return ((rainfall, water), tf.ones(1))