Skip to content

Commit

Permalink
feat(aug): configurable online mask delta augmentation by x and y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
pnsuau authored and pnsuau committed Nov 16, 2022
1 parent 684b413 commit dfa6459
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
19 changes: 12 additions & 7 deletions data/online_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,18 @@ def crop_image(
xmax = math.floor(int(bbox[3]) * ratio_x)
ymax = math.floor(int(bbox[4]) * ratio_y)

if (
mask_delta > 0
): # increase mask box so that it can fit the reconstructed object (for semantic loss)
ymin -= mask_delta
ymax += mask_delta
xmin -= mask_delta
xmax += mask_delta
if len(mask_delta) == 1:
mask_delta_x = mask_delta[0]
mask_delta_y = mask_delta[0]
elif len(mask_delta) == 2:
mask_delta_x = mask_delta[0]
mask_delta_y = mask_delta[1]

if mask_delta_x > 0 or mask_delta_y > 0:
ymin -= mask_delta_y
ymax += mask_delta_y
xmin -= mask_delta_x
xmax += mask_delta_x

if mask_square:
sdiff = (xmax - xmin) - (ymax - ymin)
Expand Down
10 changes: 6 additions & 4 deletions options/base_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,9 @@ def initialize(self, parser):
parser.add_argument(
"--data_online_creation_mask_delta_A",
type=int,
default=0,
help="mask offset to allow generation of a bigger object in domain B (for semantic loss) for domain A",
default=[0],
nargs="*",
help="mask offset to allow generation of a bigger object in domain B (for semantic loss) for domain A, format : width (x) height (y) or only one size if square",
)
parser.add_argument(
"--data_online_creation_mask_square_A",
Expand Down Expand Up @@ -629,8 +630,9 @@ def initialize(self, parser):
parser.add_argument(
"--data_online_creation_mask_delta_B",
type=int,
default=0,
help="mask offset to allow genaration of a bigger object in domain B (for semantic loss) for domain B",
default=[0],
nargs="*",
help="mask offset to allow genaration of a bigger object in domain B (for semantic loss) for domain B, format : width (y) height (x) or only one size if square",
)
parser.add_argument(
"--data_online_creation_mask_square_B",
Expand Down

0 comments on commit dfa6459

Please sign in to comment.