I am testing masks the preprocessing stages provided in the 2nd assignment of C4 Wk3 on my own PING masks, namely
def process_path(image_path, mask_path):
img = tf.io.read_file(image_path)
img = tf.image.decode_png(img, channels=3)
img = tf.image.convert_image_dtype(img, tf.float32)mask = tf.io.read_file(mask_path) mask = tf.image.decode_png(mask, channels=0) mask = tf.math.reduce_max(mask, axis=-1, keepdims=True) return img, mask
When applying this code to my own ping mask images (grayscale, 7 classes, pixel values 0 to 6), the converted images are 0 at all pixels. This happens regardless of the “channels” parameter (set to 0 , 1 or 3), whether or not I use the reduce_max function, with or without keepdims = True.
The data checks earlier in the assignment, namely
img = imageio.imread(image_list[0])
mask = imageio.imread(mask_list[0])
show good “img” and corresponding “mask”. In other words, imread reads the mask files well, tf.io.decode does not. I tried a workaround using imread, but I could not get it to work for the dataset.
Please help, and thanks beforehand.