Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion augraphy/base/augmentationpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from augraphy.base.augmentation import Augmentation
from augraphy.base.augmentationresult import AugmentationResult
from augraphy.base.augmentationsequence import AugmentationSequence
from augraphy.base.oneof import OneOf
from augraphy.utilities.detectdpi import dpi_resize
from augraphy.utilities.detectdpi import DPIMetrics
from augraphy.utilities.overlaybuilder import OverlayBuilder
Expand Down Expand Up @@ -750,7 +751,11 @@ def apply_phase(self, data, layer, phase):
data["log"]["time"].append((augmentation, elapsed))

# not "OneOf" or "AugmentationSequence"
if isinstance(augmentation, Augmentation):
if (
isinstance(augmentation, Augmentation)
and not isinstance(augmentation, AugmentationSequence)
and not isinstance(augmentation, OneOf)
):
# unpacking augmented image, mask, keypoints and bounding boxes from output
if (mask is not None) or (keypoints is not None) or (bounding_boxes is not None):
result, mask, keypoints, bounding_boxes = result
Expand Down
3 changes: 2 additions & 1 deletion augraphy/base/augmentationsequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ def __call__(self, image, layer=None, mask=None, keypoints=None, bounding_boxes=
elif isinstance(current_result, tuple):
if current_result[0] is not None:
result = current_result

if (mask is not None) or (keypoints is not None) or (bounding_boxes is not None):
result = (result, mask, keypoints, bounding_boxes)
return result, self.augmentations
6 changes: 4 additions & 2 deletions augraphy/base/oneof.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ def __call__(self, image, layer=None, mask=None, keypoints=None, bounding_boxes=
augmentation = self.augmentations[np.argmax(self.augmentation_probabilities)]

# Applies the selected Augmentation.
image = augmentation(image, mask=mask, keypoints=keypoints, bounding_boxes=bounding_boxes, force=True)
return image, [augmentation]
result = augmentation(image, mask=mask, keypoints=keypoints, bounding_boxes=bounding_boxes, force=True)
if isinstance(augmentation, AugmentationSequence):
return result[0], result[1]
return result, [augmentation]

# Constructs a string containing the representations
# of each augmentation
Expand Down