Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make adjust_hue() work with numpy 2.0 #8463

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading