Skip to content

Commit fb4fb59

Browse files
committed
Use better way from warning
1 parent 0670bc1 commit fb4fb59

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

torchvision/transforms/_functional_pil.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,8 @@ 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-
with np.errstate(over="ignore"):
113-
shift = int(hue_factor * 255)
114-
if shift > 0:
115-
np_h += shift
116-
else:
117-
np_h -= abs(shift)
112+
# This will over/underflow, as desired
113+
np_h += np.array(hue_factor * 255).astype(np.uint8)
118114

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

0 commit comments

Comments
 (0)