Skip to content

Feature/select-last-checkpoint-segmentation#157

Merged
michele-milesi merged 8 commits into
mainfrom
feature/last-checkpoint
May 21, 2026
Merged

Feature/select-last-checkpoint-segmentation#157
michele-milesi merged 8 commits into
mainfrom
feature/last-checkpoint

Conversation

@michele-milesi
Copy link
Copy Markdown
Member

Summary

Describe the purpose of the pull request, including:

Added

  • checkpoint_selection parameter in task/segmentation config (values: best, last; default: best). Controls which checkpoint is loaded for test evaluation and model export in Segmentation task.

Fixed

  • MixVisionTransformerEncoder TorchScript export on GPU: replaced hard-coded torch.empty(...) dummy tensor with x.new_empty(...) so the device and dtype are no longer baked as constants into the TorchScript graph. Without this patch, exporting and running MiT-based segmentation models (e.g. mit_b0) on GPU raised a RuntimeError. The fix is applied automatically at the start of main() via patch_mix_transformer_encoder() and will be removed once upstream segmentation_models_pytorch ships the correction.
  • cumulative_histogram.png is now uploaded as an MLflow (and TensorBoard) artifact in anomaly tasks alongside test_confusion_matrix.png and avg_score_by_label.csv.

Type of Change

Please select the one relevant option below:

  • New feature (non-breaking change that adds functionality)

Checklist

Please confirm that the following tasks have been completed:

  • I have tested my changes locally and they work as expected. (Please describe the tests you performed.)
  • I have added unit tests for my changes, or updated existing tests if necessary.
  • I have updated the documentation, if applicable.
  • I have installed pre-commit and run locally for my code changes.

Copy link
Copy Markdown

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 adds checkpoint selection for segmentation exports/evaluation, patches MiT segmentation encoder TorchScript export behavior, and updates anomaly artifact uploads with supporting tests and documentation.

Changes:

  • Added task.checkpoint_selection for segmentation tasks.
  • Patched SMP MiT encoder registration to use a Quadra-specific TorchScript-safe encoder.
  • Added/updated tests, docs, changelog, and version metadata.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
quadra/tasks/segmentation.py Adds checkpoint selection for test/export.
quadra/configs/task/segmentation.yaml Exposes default checkpoint selection config.
quadra/utils/segmentation.py Adds patched MiT encoder and registry patch helper.
quadra/main.py Applies the encoder patch during startup.
quadra/tasks/anomaly.py Uploads cumulative histogram artifacts.
quadra/tasks/classification.py Adds type-ignore for GradCAM indexing.
quadra/utils/tests/fixtures/models/segmentation.py Adds patched mit_b0 segmentation fixture.
tests/utilities/test_segmentation_utils.py Tests MiT encoder patch behavior.
tests/tasks/test_segmentation.py Tests checkpoint selection and MiT export/inference.
tests/tasks/test_anomaly.py Adds input shape override for CS-Flow test.
tests/models/test_export.py Adds MiT TorchScript export regression tests.
docs/tutorials/export.md Documents segmentation checkpoint selection for export.
docs/tutorials/examples/segmentation.md Documents segmentation checkpoint selection in tutorial config.
CHANGELOG.md Adds 2.9.0 release notes.
quadra/__init__.py Bumps package version.
pyproject.toml Bumps Poetry package version.

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

Comment thread quadra/tasks/segmentation.py
Comment thread tests/tasks/test_segmentation.py Outdated
Comment thread tests/models/test_export.py Outdated
Comment thread docs/tutorials/export.md Outdated
Comment thread quadra/main.py Outdated
@michele-milesi michele-milesi marked this pull request as ready for review May 15, 2026 10:53
@michele-milesi michele-milesi merged commit e0ee238 into main May 21, 2026
1 check 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.

4 participants