Skip to content

Conversation

@mihow
Copy link
Collaborator

@mihow mihow commented Sep 11, 2025

This PR fixes incorrect logits being returned in the API by restructuring how classifier results are handled and returned. The changes address issue #91 by ensuring logits are properly separated from scores in classification responses.

  • Returns the actual logits from the model output rather than a copy of the softmax scores
  • Introduces a new ClassifierResult dataclass to standardize classifier output format
  • Add test coverage for expected logits and scores
  • Fixes the test setup for all previous API tests that were passing because no images were in the tests requests.
  • Fixes the test failures introduced in Remove algorithm and category map details in every result response #93 (but were passing because of the discovered test setup issue)

@sentry
Copy link

sentry bot commented Sep 11, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: trapdata/api/models/classification.py

Function Unhandled Issue
save_results ValidationError: 2 validation errors for ClassificationResponse /pi...
Event Count: 2
📄 File: trapdata/ml/models/base.py (Click to Expand)
Function Unhandled Issue
run ValidationError: 2 validation errors for ClassificationResponse /pi...
Event Count: 2
run NameError: name 'ceil' is not defined /process
Event Count: 1
---

Did you find this useful? React with a 👍 or 👎

@mihow mihow changed the title Fix/incorrect logits Fix incorrect logits returned in API Sep 11, 2025
@mihow mihow requested a review from Copilot September 11, 2025 02:40
Copy link
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 PR fixes incorrect logits being returned in the API by restructuring how classifier results are handled and returned. The changes address issue #91 by ensuring logits are properly separated from scores in classification responses.

  • Introduces a new ClassifierResult dataclass to standardize classifier output format
  • Updates classification processing to correctly handle logits vs scores
  • Adds comprehensive test coverage for logits functionality

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
trapdata/ml/models/base.py Adds ClassifierResult dataclass to standardize classifier output
trapdata/api/tests/test_api.py Updates tests and adds new test for logits verification
trapdata/api/models/classification.py Refactors post-processing to use ClassifierResult and fix logits handling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@mihow
Copy link
Collaborator Author

mihow commented Sep 17, 2025

Part of RolnickLab/antenna#782

@mihow mihow merged commit bf0fe16 into main Sep 17, 2025
3 checks passed
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