Skip to content

Commit a7b66f0

Browse files
vfdev-5fmassa
authored andcommitted
* Replace np.random by random (#354)
1 parent 3ce7ded commit a7b66f0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

torchvision/transforms/transforms.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -700,22 +700,22 @@ def get_params(brightness, contrast, saturation, hue):
700700
"""
701701
transforms = []
702702
if brightness > 0:
703-
brightness_factor = np.random.uniform(max(0, 1 - brightness), 1 + brightness)
703+
brightness_factor = random.uniform(max(0, 1 - brightness), 1 + brightness)
704704
transforms.append(Lambda(lambda img: F.adjust_brightness(img, brightness_factor)))
705705

706706
if contrast > 0:
707-
contrast_factor = np.random.uniform(max(0, 1 - contrast), 1 + contrast)
707+
contrast_factor = random.uniform(max(0, 1 - contrast), 1 + contrast)
708708
transforms.append(Lambda(lambda img: F.adjust_contrast(img, contrast_factor)))
709709

710710
if saturation > 0:
711-
saturation_factor = np.random.uniform(max(0, 1 - saturation), 1 + saturation)
711+
saturation_factor = random.uniform(max(0, 1 - saturation), 1 + saturation)
712712
transforms.append(Lambda(lambda img: F.adjust_saturation(img, saturation_factor)))
713713

714714
if hue > 0:
715-
hue_factor = np.random.uniform(-hue, hue)
715+
hue_factor = random.uniform(-hue, hue)
716716
transforms.append(Lambda(lambda img: F.adjust_hue(img, hue_factor)))
717717

718-
np.random.shuffle(transforms)
718+
random.shuffle(transforms)
719719
transform = Compose(transforms)
720720

721721
return transform
@@ -782,7 +782,7 @@ def get_params(degrees):
782782
Returns:
783783
sequence: params to be passed to ``rotate`` for random rotation.
784784
"""
785-
angle = np.random.uniform(degrees[0], degrees[1])
785+
angle = random.uniform(degrees[0], degrees[1])
786786

787787
return angle
788788

0 commit comments

Comments
 (0)