Error in transform_to_normalized_grayscale
matheushent opened this issue · 2 comments
I have been debugging some functions and I noticed that transform_to_normalized_grayscale defined in tf_explain/utils/image doesn't return a 4D tensor as described in function.
I think the channels axis is being totally disconsidered. So, the keepdims argument inside reduce_sum must be set to True, furthermore tf.reduce_sum
would be properly changed by tf.math.reduce_sum
.
In other words:
grayscale_tensor = tf.math.reduce_sum(tensor, axis=-1, keepdims=True)
instead of
grayscale_tensor = tf.reduce_sum(tensor, axis=-1)
I am a little bit lost about what exactly transform_to_normalized_grayscale does. The output of this function just gives me completely black images instead of gray scale images.
@matheushent Totally agree with you. This function does too much things and should be split into multiple ones. At the moment:
- apply sum along axis and transforms the input of shape (H, W, C) into (H, W, 1)
- cast from float to integers
Hope it helps a bit, will try to make it cleaner