Skip to content

Commit

Permalink
Fix contrast mean value for float32 and factor=0 (#1207)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dipet committed Jul 9, 2022
1 parent a4d33e1 commit ca59440
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion albumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,9 @@ def adjust_contrast_torchvision(img, factor):
mean = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY).mean()

if factor == 0:
return np.full_like(img, int(mean + 0.5), dtype=img.dtype)
if img.dtype != np.float32:
mean = int(mean + 0.5)
return np.full_like(img, mean, dtype=img.dtype)

if img.dtype == np.uint8:
return _adjust_contrast_torchvision_uint8(img, factor, mean)
Expand Down

0 comments on commit ca59440

Please sign in to comment.