Derive prediction probability shape from class_names in save_predictions#387
Open
gbeane wants to merge 2 commits into
Open
Derive prediction probability shape from class_names in save_predictions#387gbeane wants to merge 2 commits into
gbeane wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates Project.save_predictions to allocate the probability array shape based on whether class_names is provided (multi-class) vs omitted (binary), fixing shape mismatches when saving empty multi-class predictions, and adds targeted tests to lock in the expected HDF5 output shapes.
Changes:
- Allocate
prediction_probas(n_identities, n_frames, n_classes)whenclass_namesis provided, otherwise(n_identities, n_frames). - Add tests covering empty and non-empty multi-class saves plus binary saves, asserting stored HDF5 dataset shapes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/jabs/project/project.py |
Changes probability-array allocation logic in save_predictions to derive shape from class_names. |
tests/project/test_project.py |
Adds regression tests verifying saved probability dataset shapes for multi-class and binary predictions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
This pull request updates how probability arrays are allocated and stored in the
save_predictionsmethod, ensuring that the shape of the probability array is determined by the presence ofclass_namesrather than by inspecting the contents of theprobabilitiesdictionary. This change fixes shape mismatches for empty multi-class predictions and is verified with new targeted tests.Probability array allocation and shape logic:
src/jabs/project/project.py: The logic for allocating theprediction_probarray insave_predictionsnow uses theclass_namesargument to determine shape, ensuring that even whenprobabilitiesis empty, the correct (n_identities, n_frames, n_classes) shape is used for multi-class predictions, and (n_identities, n_frames) for binary predictions.Testing improvements:
tests/project/test_project.py: Added new tests to verify thatsave_predictionsallocates and writes probability arrays with the correct shape for both empty and non-empty multi-class predictions, as well as for binary predictions.tests/project/test_project.py: Added minimal stand-in objects for pose estimation and classifier to support the new tests.tests/project/test_project.py: Added necessary imports forh5pyand theMULTICLASS_PREDICTION_KEYconstant. [1] [2]