Skip to content

Commit ab0b9a4

Browse files
authored
Make adjust_hue() work with numpy 2.0 (#8463)
1 parent 6e18cea commit ab0b9a4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

torchvision/transforms/_functional_pil.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ def adjust_hue(img: Image.Image, hue_factor: float) -> Image.Image:
109109
h, s, v = img.convert("HSV").split()
110110

111111
np_h = np.array(h, dtype=np.uint8)
112-
# uint8 addition take cares of rotation across boundaries
113-
with np.errstate(over="ignore"):
114-
np_h += np.uint8(hue_factor * 255)
112+
# This will over/underflow, as desired
113+
np_h += np.array(hue_factor * 255).astype(np.uint8)
114+
115115
h = Image.fromarray(np_h, "L")
116116

117117
img = Image.merge("HSV", (h, s, v)).convert(input_mode)

0 commit comments

Comments
 (0)