Skip to content

Commit

Permalink
Merge pull request #439 from mezotaken/oneof_fix
Browse files Browse the repository at this point in the history
Fix OneOf so it could choose random augmentation on each subsequent call, instead of choosing once on initialization.
  • Loading branch information
kwcckw authored Jul 18, 2024
2 parents eeb23d6 + 5dff5bd commit f89615c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion augraphy/base/oneof.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ class OneOf(Augmentation):
def __init__(self, augmentations, p=1):
"""Constructor method"""
self.augmentations = augmentations
self.augmentation_probabilities = self.compute_probability(self.augmentations)
self.p = p

# Randomly selects an Augmentation to apply to data.
def __call__(self, image, layer=None, mask=None, keypoints=None, bounding_boxes=None, force=False):
if force or self.should_run():

# Select one augmentation using the max value in probability values
self.augmentation_probabilities = self.compute_probability(self.augmentations)
augmentation = self.augmentations[np.argmax(self.augmentation_probabilities)]

# Applies the selected Augmentation.
Expand Down

0 comments on commit f89615c

Please sign in to comment.