Skip to content Skip to sidebar Skip to footer

How To Fix "typeerror: X And Y Must Have The Same Dtype, Got Tf.uint8 != Tf.float32" When I Try To Resize An Image In Tensorflow

I try to setup an images pipeline that builds an images dataset for Tensorflow that crops the images, but I fail at cropping the picture. I followed this tutorial but I want to cro

Solution 1:

Tensorflow doesn't do automatic type casting. It seems that the decoded image is a tensor with dtype tf.uint8, you have to cast it to tf.float32 for the division to work as you expect.

Replace

img_final /= 255.0

with

img_final = tf.cast(img_final, tf.float32) / 255.0

Post a Comment for "How To Fix "typeerror: X And Y Must Have The Same Dtype, Got Tf.uint8 != Tf.float32" When I Try To Resize An Image In Tensorflow"