tf.image.rgb_to_hsv and tf.image.hsv_to_rgb are not numerically reversible for large float32 inputs
Author: syan427Created Oct 10, 2025Updated Sep 17, 2026
Labelsstat:awaiting responsetype:bugcomp:apiscomp:opsTF 2.13
Issue type
Bug
Have you reproduced the bug with TensorFlow Nightly?
Yes
Source
source
TensorFlow version
tf 2.13.0
Custom code
Yes
OS platform and distribution
Ubuntu 20.04
Mobile device
No response
Python version
3.9
Bazel version
No response
GCC/compiler version
No response
CUDA/cuDNN version
No response
GPU model and memory
No response
Current behavior?
For very large float32 RGB values (on the order of 1e38), the pair of functions tf.image.rgb_to_hsv → tf.image.hsv_to_rgb fails to recover the original input values.
tf.image.rgb_to_hsv() produces finite outputs.
tf.image.hsv_to_rgb() does not return the same RGB tensor — values differ significantly even though both functions should be approximately reversible.
Standalone code to reproduce the issue
import numpy as np
import tensorflow as tf
x = np.array([[[1.0870518e+38, 2.0447458e+38, 6.2133610e+37]]],
dtype=np. float32)
tf_result1 = tf.image.rgb_to_hsv(x)
#[[[3.3333334e-01, 6.9613039e-01, 2.0447458e+38]]]
tf_result2 = tf.image.hsv_to_rgb(tf_result1)
#[[[6.2133610e+37, 2.0447458e+38,6.2133610e+37]]]
print(tf_result1)
print(tf_result2)
Relevant log output
[[[3.3333334e-01, 6.9613039e-01, 2.0447458e+38]]]
[[[6.2133610e+37, 2.0447458e+38,6.2133610e+37]]]
Source: tensorflow/tensorflow