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 error when image mixup hyperparam is non-zero for instance segmentation training on u7 #1928

Open
wants to merge 1 commit into
base: u7
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions seg/utils/segment/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ def mixup(im, labels, segments, im2, labels2, segments2):
r = np.random.beta(32.0, 32.0) # mixup ratio, alpha=beta=32.0
im = (im * r + im2 * (1 - r)).astype(np.uint8)
labels = np.concatenate((labels, labels2), 0)
segments = np.concatenate((segments, segments2), 0)
# Handle cases if segments or segments2 is empty if no labels. It is a list if empty.
# TODO handle this issue upstream before ingestion of segments. This is a quick fix.
if isinstance(segments2, list):
return im, labels, segments
elif isinstance(segments, list):
return im, labels, segments2
else:
segments = np.concatenate((segments, segments2), 0)
return im, labels, segments


Expand Down Expand Up @@ -101,4 +108,4 @@ def random_perspective(im,
targets[:, 1:5] = new[i]
new_segments = np.array(new_segments)[i]

return im, targets, new_segments
return im, targets, new_segments