-
Notifications
You must be signed in to change notification settings - Fork 253
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 bugs with passing images_background to AnchorImage #542
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,13 +221,12 @@ def perturbation( | |
segments_mask[:, anchor] = 1 | ||
|
||
# for each sample, need to sample one of the background images if provided | ||
if self.images_background: | ||
if self.images_background is not None: | ||
backgrounds = np.random.choice( | ||
range(len(self.images_background)), | ||
segments_mask.shape[0], | ||
replace=True, | ||
) | ||
segments_mask = np.hstack((segments_mask, backgrounds.reshape(-1, 1))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line appears to be completely random and just doesn't work. |
||
else: | ||
backgrounds = [None] * segments_mask.shape[0] | ||
# create fudged image where the pixel value in each superpixel is set to the | ||
|
@@ -247,13 +246,11 @@ def perturbation( | |
mask = np.zeros(segments.shape).astype(bool) | ||
for superpixel in to_perturb: | ||
mask[segments == superpixel] = True | ||
if background_idx: | ||
if background_idx is not None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main bug. Here |
||
# replace values with those of background image | ||
# TODO: Could images_background be None herre? | ||
temp[mask] = self.images_background[background_idx][mask] | ||
else: | ||
# ... or with the averaged superpixel value | ||
# TODO: Where is fudged_image defined? | ||
temp[mask] = fudged_image[mask] | ||
pert_imgs.append(temp) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.images_background
is eitherNone
ornp.ndarray
so we must check explicitly forNone
asnp.ndarray
doesn't have a working__bool__
method.