Skip to content

Feat(Segmentation): algorithm-dependent model constraints - #1061

Open
jdeschamps wants to merge 3 commits into
mainfrom
jd/feat/model_constraints_from_algo
Open

Feat(Segmentation): algorithm-dependent model constraints#1061
jdeschamps wants to merge 3 commits into
mainfrom
jd/feat/model_constraints_from_algo

Conversation

@jdeschamps

@jdeschamps jdeschamps commented Aug 24, 2026

Copy link
Copy Markdown
Member

Semantic segmentation requires different model constraints from restoration algorithms because the model output has different shape than the target arrays. Indeed, model output are logits/probability per class while the target are class labels (no "C" dimension).

This PR changes the parameter passed to get_model_constraints from the model configuration to the algorithm configuration.

# before
def get_model_constraints(model_config: UNetConfig) -> ModelConstraints:

# now
def get_model_constraints(algorithm_config: AlgorithmConfig) -> ModelConstraints:

It also adds the segmentation constraints class.

Changes

Added

  • Segmentation constraints
    • Inherit from Unet constraints to reuse validation
    • Here, validate_target_channels needs to ensure that targets are class labels by checking it is a singleton channel

Modified

  • Update get_model_constraints to take in the algorithm configuration and accommodate segmentation constraints.
  • Update SupportedAlgorithms to accommodate segmentation, reorganizes order.
  • Update Configuration and CAREamist to pass the correct configuration (algorithm, not model) to get_model_constraints

Notes

Part of splitting #986 into smaller PRs.

@jdeschamps
jdeschamps requested a review from a team August 24, 2026 14:32
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.57%. Comparing base (d70cc4b) to head (98f961d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...reamics/models/constraints/seg_unet_constraints.py 62.50% 3 Missing ⚠️
...cs/models/constraints/model_constraints_factory.py 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1061      +/-   ##
==========================================
- Coverage   87.59%   87.57%   -0.03%     
==========================================
  Files         251      252       +1     
  Lines        8903     8914      +11     
==========================================
+ Hits         7799     7806       +7     
- Misses       1104     1108       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jdeschamps jdeschamps changed the title Feat: algorithm-dependent model constraints Feat(Segmentation): algorithm-dependent model constraints Aug 24, 2026
@jdeschamps
jdeschamps force-pushed the jd/feat/model_constraints_from_algo branch from c85d3a9 to 98f961d Compare August 25, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant