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

Add multi-batch prediction for the segmentation and Polaris consumers #189

Merged
merged 27 commits into from
May 2, 2022

Conversation

elaubsch
Copy link
Member

@elaubsch elaubsch commented Apr 29, 2022

This PR adds support for multi-batch images for the segmentation and Polaris consumers. The segmentation consumer receives a variable dimension_order from the frontend (see this PR). This variable has been added to the data generated by the Polaris consumer for segmentation jobs.

We have also added more comprehensive testing of the segmentation consumer for input images of different dimension orders. This involved changes to the DummyStorage object to allow the dimensions of the images it generates to be specified.

We have removed a line from the get_image utils function that expands the dimensions of loaded TIFF files by default, because this behavior complicated the handling of images with dimensions BXYC or CXYB. This change had little impact on the other functions that call get_image, because this channel was often squeezed out immediately after loading.

@elaubsch elaubsch requested a review from msschwartz21 April 29, 2022 23:28
Copy link
Member

@msschwartz21 msschwartz21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this change! I think it's a big improvement to functionality for segmentation.

Let me know how you want to handle the minor comments and then I'm happy to approve.

@@ -191,11 +195,11 @@ def _load_data(self, redis_hash, subdir, fname):
labels = [frames[i] for i in range(num_frames)]

# Cast y to int to avoid issues during fourier transform/drift correction
y = np.array(labels, dtype='uint16')
y = np.expand_dims(np.array(labels, dtype='uint16'), axis=-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this essentially adding back a channel dimension?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the tracking model needs it to be 4D and the segmentation consumer is currently returning a 3D image (BXY)

Comment on lines 199 to +202
# TODO: Why is there an extra dimension?
# Not a problem in tests, only with application based results.
# Issue with batch dimension from outputs?
y = y[:, 0] if y.shape[1] == 1 else y
# y = y[:, 0] if y.shape[1] == 1 else y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on deleting vs. leaving commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about when the 1st dimension would be 1 so I was worried that we were neglecting an edge case that would make this line relevant, but I don't feel strongly, we could delete it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it just in case we end up debugging the edge case in the future.

redis_consumer/consumers/segmentation_consumer.py Outdated Show resolved Hide resolved
@msschwartz21 msschwartz21 added the enhancement New feature or request label Apr 30, 2022
@elaubsch elaubsch requested a review from msschwartz21 April 30, 2022 05:34
Copy link
Member

@msschwartz21 msschwartz21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@elaubsch elaubsch merged commit e61342a into master May 2, 2022
@elaubsch elaubsch deleted the mly/segmentation branch May 2, 2022 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants