Skip to content

Enhance Detector class with feature extraction and accuracy#57

Open
krataratha wants to merge 1 commit into
mapooon:masterfrom
krataratha:patch-1
Open

Enhance Detector class with feature extraction and accuracy#57
krataratha wants to merge 1 commit into
mapooon:masterfrom
krataratha:patch-1

Conversation

@krataratha

Copy link
Copy Markdown

Added feature to extract raw embedding features and calculate batch accuracy during training.

Added feature to extract raw embedding features and calculate batch accuracy during training.
Copilot AI review requested due to automatic review settings June 20, 2026 14:59

Copilot AI left a comment

Copy link
Copy Markdown

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 enhances the Detector model API to optionally return EfficientNet feature maps (via return_features) and attempts to return batch accuracy from training_step during SAM-based training.

Changes:

  • Added return_features flag to Detector.forward() to return net.extract_features(x) instead of logits.
  • Refactored SAM step selection in training_step() using a step_fn variable.
  • Updated training_step() to compute and return batch accuracy (but currently changes the return type).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/model.py
Comment on lines +36 to 40
# Feature: Now calculates and returns batch accuracy alongside the predictions
acc = (pred_first.argmax(dim=-1) == target).float().mean()
return pred_first, loss, acc

return pred_first
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