Closed JLrumberger closed 1 year ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
I'll add a few more tests for the viewer widget tomorrow and then will merge this PR before the workshop. Is that okay @ngreenwald ?
What is the purpose of this PR?
This PR closes #64 and adds the class
Nimbus
which extends the classdeepcell.applications.Application
and gives an interface for all things inference. The class first checks its inputs, loads the model, then prepares the normalization dictionary and does predictions. In addition, the classNimbusViewer
implements a viewer widget, than can be used to scroll through FOVs and show input channels and output predictions side by side for visual inspection of the results. Both classes are used in thepredict.ipynb
to first predict model confidence scores and then inspect them.How did you implement your changes
I added several functions to
inference.py
that implement a functional interface for inference. The following functions are thereprepare_normalization_dict
: iterates through FoVs and calculates the normalization quantile. Has the option to run parallel via joblib.prepare_input_data
: turns the segmentation map to a binary representation with eroded edgessegment_mean
: takes instance segmentation map and another image and returns mean per cell expression profiles.test_time_aug
: Does inference over a batch of flipped and 90°-rotated images and returns the average over these transformations. This is known to improve results slightly.predict_fovs
: iterates through fovs and predictsI added the class
Nimbus
that extendsdeepcell.applications.Application
and gives a class-based interface to the above mentioned inference functions.check_input
: Checks the input for correctnessinitialize_model
: Initializes ML model and loads the model checkpointprepare_normalization_dict
: does what it says :)predict_fovs
: iteratives through fovs, predicts and stores themNimbusViewer
is a class that implements an ipywidget to view multiplexed channels and predicted model confidence scores side-by-side and allows the user to choose which FOV and channels to look at.Remaining issues
NimbusViewer
does not have tests yet. I'll look into the Pixie repo to see how widgets can be tested.