Skip to content

Commit

Permalink
[fbsync] Make adjust_hue() work with numpy 2.0 (#8463)
Browse files Browse the repository at this point in the history
Reviewed By: vmoens

Differential Revision: D58283860

fbshipit-source-id: 37261b4d0ca78666ef01d9b04937bd02870f81e2
  • Loading branch information
NicolasHug authored and facebook-github-bot committed Jun 7, 2024
1 parent 06c8966 commit ddd9b4d
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 ddd9b4d

Please sign in to comment.