dataset: namespace → dict

Python is so annoying
This commit is contained in:
Starbeamrainbowlabs 2022-09-02 16:07:44 +01:00
parent dbff15d4a9
commit c066ea331b
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -20,13 +20,13 @@ def parse_item(metadata):
}) })
rainfall = tf.io.parse_tensor(parsed["rainfallradar"], out_type=tf.float32) rainfall = tf.io.parse_tensor(parsed["rainfallradar"], out_type=tf.float32)
water = tf.io.parse_tensor(parsed["waterdepth"], out_type=tf.float32) water = tf.io.parse_tensor(parsed["waterdepth"], out_type=tf.float32)
# [channels, width, height] → [width, height, channels] - ref ConvNeXt does not support data_format=channels_first # [channels, width, height] → [width, height, channels] - ref ConvNeXt does not support data_format=channels_first
rainfall = tf.transpose(rainfall, [1, 2, 0]) rainfall = tf.transpose(rainfall, [1, 2, 0])
# [width, height] → [width, height, channels] # [width, height] → [width, height, channels]
water = tf.expand_dims(water, axis=-1) water = tf.expand_dims(water, axis=-1)
# BUG: AttributeError: 'dict' object has no attribute 'waterdepth # BUG: AttributeError: 'dict' object has no attribute 'waterdepth
rainfall = tf.image.resize(rainfall, tf.constant(metadata.waterdepth)) rainfall = tf.image.resize(rainfall, tf.constant(metadata["waterdepth"]))
# TODO: The shape of the resulting tensor can't be statically determined, so we need to reshape here # 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) print("DEBUG:dataset ITEM rainfall:shape", rainfall.shape, "water:shape", water.shape)