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

Unwrap line string augmentation #450

Merged
merged 28 commits into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7a4ad2c
Add tests for line strings in .blend module
aleju Oct 1, 2019
bc0c380
Add tests for line strings in .flip module
aleju Oct 1, 2019
0f062cc
Add tests for line strings and bounding boxes in Affine
aleju Oct 1, 2019
7544495
Add tests for line strings in PiecewiseAffine
aleju Oct 2, 2019
b82aa91
Add tests for line strings in PerspectiveTransform
aleju Oct 2, 2019
e46c2c9
Add tests for line strings in ElasticTransformation
aleju Oct 2, 2019
7b715a1
Add tests for line strings in Rot90
aleju Oct 2, 2019
0551e9c
Add tests for line strings in Augmenter
aleju Oct 2, 2019
6c307ff
Add tests for line strings in Sequential
aleju Oct 2, 2019
3a021d2
Add tests for line strings in SomeOf
aleju Oct 2, 2019
fe4fbc7
Add tests for line strings in Sometimes
aleju Oct 2, 2019
0d58989
Add tests for line strings in WithChannels
aleju Oct 2, 2019
43648f7
Add tests for line strings in ChannelShuffle
aleju Oct 2, 2019
e3ce88b
Add tests for line strings in pooling augmenters
aleju Oct 2, 2019
1a062cb
Add tests for line strings in Resize
aleju Oct 2, 2019
cb02425
Add tests for line strings in Pad
aleju Oct 2, 2019
65c78ac
Add tests for line strings in Crop
aleju Oct 2, 2019
26f019d
Add tests for line strings in PadToFixedSize
aleju Oct 2, 2019
0b73091
Add tests for line strings in CropToFixedSize
aleju Oct 2, 2019
06f0a00
Add tests for line strings in KeepSizeByResize
aleju Oct 2, 2019
e6674df
Fix datatypes in test
aleju Oct 2, 2019
47f58e7
Add type check to assert_cbaois_equal()
aleju Oct 2, 2019
c40903a
Add _augment_line_strings() methods to augmenters
aleju Oct 2, 2019
044c6e2
Add line string tests for remaining meta augmenters
aleju Oct 2, 2019
b16a332
Improve blend tests for LS/BBs
aleju Oct 2, 2019
ef156e4
Add checks to make BBs valid after aug in Lambda
aleju Oct 2, 2019
ee00b84
Add tests for BBs becoming invalid during aug
aleju Oct 2, 2019
fef943e
Add PR ID to changelog
aleju Oct 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions changelogs/master/added/20190927_unwrapped_bb_aug.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
* [breaking] Added parameter `parents` to `Augmenter.augment_bounding_boxes()`.
This breaks if `hooks` was used as a *positional* argument in connection with
that method.
* [breaking] Added parameter `func_bounding_boxes` to `Lambda`. This
breaks if one relied on the order of the augmenter's parameters instead of
their names.
* [breaking] Added parameter `func_bounding_boxes` to `AssertLambda`. This
breaks if one relied on the order of the augmenter's parameters instead of
their names.
* [breaking] Added parameter `check_bounding_boxes` to `AssertShape`. This
breaks if one relied on the order of the augmenter's parameters instead of
their names.
* [rarely breaking] Added parameter `func_bounding_boxes` to `Lambda`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
* [rarely breaking] Added parameter `func_bounding_boxes` to `AssertLambda`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
* [rarely breaking] Added parameter `check_bounding_boxes` to `AssertShape`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
15 changes: 15 additions & 0 deletions changelogs/master/added/20191002_unwrapped_ls_aug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Unwrapped Line String Augmentation #450

* Added internal `_augment_line_strings()` methods to various augmenters.
This allows to individually control how line strings are supposed to
be augmented. Previously, the line string augmentation was a wrapper around
keypoint augmentation that did not allow such control.
* [rarely breaking] Added parameter `func_line_strings` to `Lambda`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
* [rarely breaking] Added parameter `func_line_strings` to `AssertLambda`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
* [rarely breaking] Added parameter `check_line_strings` to `AssertShape`.
This breaks if one relied on the order of the augmenter's parameters instead
of their names.
15 changes: 15 additions & 0 deletions imgaug/augmenters/blend.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,12 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
polygons_on_images, random_state, parents, hooks,
"augment_polygons")

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_nonimages(
line_strings_on_images, random_state, parents, hooks,
"augment_line_strings")

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_nonimages(
Expand Down Expand Up @@ -679,6 +685,7 @@ def __init__(self, factor=0, first=None, second=None, per_channel=False,
# keypoint mode currently also affects line strings
self._keypoints_mode = self._MODE_POINTWISE
self._polygons_mode = self._MODE_EITHER_OR
self._line_strings_mode = self._MODE_EITHER_OR
self._bounding_box_mode = self._MODE_EITHER_OR

def _augment_images(self, images, random_state, parents, hooks):
Expand Down Expand Up @@ -813,6 +820,14 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
# see notes under polygons
mode = self._line_strings_mode
with _switch_keypoint_mode_temporarily(self, mode):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
# see notes under polygons
Expand Down
13 changes: 13 additions & 0 deletions imgaug/augmenters/flip.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,13 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
# TODO maybe reverse the order of points afterwards? the flip probably
# inverts them
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -1014,6 +1021,12 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
# TODO how does flipping affect the point order?
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down
30 changes: 30 additions & 0 deletions imgaug/augmenters/geometric.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -1816,6 +1821,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -2262,6 +2272,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
polygons_on_images, random_state, parents, hooks,
recoverer=self.polygon_recoverer)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -2806,6 +2821,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
polygons_on_images, random_state, parents, hooks,
recoverer=self.polygon_recoverer)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -3424,6 +3444,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
polygons_on_images, random_state, parents, hooks,
recoverer=self.polygon_recoverer)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down Expand Up @@ -3915,6 +3940,11 @@ def _augment_polygons(self, polygons_on_images, random_state, parents,
return self._augment_polygons_as_keypoints(
polygons_on_images, random_state, parents, hooks)

def _augment_line_strings(self, line_strings_on_images, random_state,
parents, hooks):
return self._augment_line_strings_as_keypoints(
line_strings_on_images, random_state, parents, hooks)

def _augment_bounding_boxes(self, bounding_boxes_on_images, random_state,
parents, hooks):
return self._augment_bounding_boxes_as_keypoints(
Expand Down