Skip to content

Commit

Permalink
Add seed parameter for image augmentation method. (keras-team#7239)
Browse files Browse the repository at this point in the history
  • Loading branch information
hgaiser authored and fchollet committed Jul 6, 2017
1 parent 94dbc30 commit cebf208
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion keras/preprocessing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,11 +527,12 @@ def standardize(self, x):
'first by calling `.fit(numpy_data)`.')
return x

def random_transform(self, x):
def random_transform(self, x, seed=None):
"""Randomly augment a single image tensor.
# Arguments
x: 3D tensor, single image.
seed: random seed.
# Returns
A randomly transformed version of the input (same shape).
Expand All @@ -541,6 +542,9 @@ def random_transform(self, x):
img_col_axis = self.col_axis - 1
img_channel_axis = self.channel_axis - 1

if seed is not None:
np.random.seed(seed)

# use composition of homographies
# to generate final transform that needs to be applied
if self.rotation_range:
Expand Down

0 comments on commit cebf208

Please sign in to comment.