Skip to content

Commit

Permalink
Make adjust_hue() work with numpy 2.0 (#8463)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored Jun 3, 2024
1 parent 6e18cea commit ab0b9a4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torchvision/transforms/_functional_pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ab0b9a4

Please sign in to comment.