Skip to content

Derive prediction probability shape from class_names in save_predictions#387

Open
gbeane wants to merge 2 commits into
feature/multiclassfrom
fix/multiclass-save-predictions-shape
Open

Derive prediction probability shape from class_names in save_predictions#387
gbeane wants to merge 2 commits into
feature/multiclassfrom
fix/multiclass-save-predictions-shape

Conversation

@gbeane
Copy link
Copy Markdown
Collaborator

@gbeane gbeane commented Jun 1, 2026

This pull request updates how probability arrays are allocated and stored in the save_predictions method, ensuring that the shape of the probability array is determined by the presence of class_names rather than by inspecting the contents of the probabilities dictionary. 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 the prediction_prob array in save_predictions now uses the class_names argument to determine shape, ensuring that even when probabilities is 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 that save_predictions allocates 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 for h5py and the MULTICLASS_PREDICTION_KEY constant. [1] [2]

@gbeane gbeane requested a review from Copilot June 1, 2026 16:00
@gbeane gbeane self-assigned this Jun 1, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_prob as (n_identities, n_frames, n_classes) when class_names is 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.

Comment thread src/jabs/project/project.py
@gbeane gbeane requested review from bergsalex, Copilot and keithshep June 1, 2026 17:33
@gbeane gbeane marked this pull request as ready for review June 1, 2026 17:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants