Skip to content

Commit

Permalink
Merge branch 'np2-hue' into np2
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Jun 3, 2024
2 parents 6012d8a + fb4fb59 commit 46ef777
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions torchvision/transforms/_functional_pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,8 @@ 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)
with np.errstate(over="ignore"):
shift = int(hue_factor * 255)
if shift > 0:
np_h += shift
else:
np_h -= abs(shift)
# This will over/underflow, as desired
np_h += np.array(hue_factor * 255).astype(np.uint8)

h = Image.fromarray(np_h, "L")

Expand Down

0 comments on commit 46ef777

Please sign in to comment.