Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix OneOf and AugmentationsSequence to process bboxes properly #446

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
5 changes: 4 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,9 @@ 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
2 changes: 1 addition & 1 deletion augraphy/base/augmentationsequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ 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

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