diff --git a/torchvision/transforms/_functional_pil.py b/torchvision/transforms/_functional_pil.py index 277848224ac..527879bb6f1 100644 --- a/torchvision/transforms/_functional_pil.py +++ b/torchvision/transforms/_functional_pil.py @@ -109,9 +109,9 @@ def adjust_hue(img: Image.Image, hue_factor: float) -> Image.Image: h, s, v = img.convert("HSV").split() np_h = np.array(h, dtype=np.uint8) - # uint8 addition take cares of rotation across boundaries - with np.errstate(over="ignore"): - np_h += np.uint8(hue_factor * 255) + # This will over/underflow, as desired + np_h += np.array(hue_factor * 255).astype(np.uint8) + h = Image.fromarray(np_h, "L") img = Image.merge("HSV", (h, s, v)).convert(input_mode)