Repository navigation
feat: allow prediction directly on in-memory numpy arrays and PIL images (closes #47) - #89
Open
ashishsoni-ai wants to merge 1 commit into
Open
ashishsoni-ai wants to merge 1 commit into
ashishsoni-ai wants to merge 1 commit into
Conversation
…ges (closes DevoLearn#47) - Added load_image utility to InferenceEngine base class to standardize input across file paths, 2D/3D/float numpy arrays, and PIL Images. - Updated cell_membrane_segmentor.predict, cell_nucleus_segmentor.predict, and lineage_population_model.predict to accept in-memory arrays as well as paths. - Preserved backward compatibility for image_path argument. - Fixed InferenceEngine.__repr__ to return str instead of nn.Module object. - Added comprehensive unit tests in devolearn/tests/test.py covering numpy and PIL predictions across all models. - Updated README.md documentation with an in-memory array prediction example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves #47.
Currently, models in \devolearn\ only allow inference on images by specifying a file path on disk. If users have loaded image data in memory as a NumPy array (e.g. from OpenCV, video frames, preprocessing pipelines, or synthetic generators) or a PIL Image, they previously had to write the image to a temporary file on disk first before calling .predict().
This PR extends the .predict()\ method across all models (\cell_membrane_segmentor, \cell_nucleus_segmentor, and \lineage_population_model) to directly accept in-memory NumPy arrays and PIL Images in addition to file paths, while maintaining full backward compatibility.
Changes Made
**Added \InferenceEngine.load_image()**:
Updated Model \predict()\ Signatures & Implementations:
**Fixed \InferenceEngine.repr**:
n.Module\ object, avoiding \TypeError: repr returned non-string\ during debugging, logging, or test failure reporting.
Testing:
Documentation: