def tf_read_img(tf, filename):
    """Loads a image file as float32 HxWx3 array; tested to work on png and jpg images."""
    string = tf.read_file(filename)
    image = tf.image.decode_image(string, channels=3)
    image = tf.cast(image, tf.float32)
    image /= 255
    return image