Skip to content

Add MC-Dropout uncertainty estimation for patch classification - #1104

Open
Pier45 wants to merge 2 commits into
TissueImageAnalytics:developfrom
Pier45:feature/mc-dropout-uncertainty
Open

Add MC-Dropout uncertainty estimation for patch classification#1104
Pier45 wants to merge 2 commits into
TissueImageAnalytics:developfrom
Pier45:feature/mc-dropout-uncertainty

Conversation

@Pier45

@Pier45 Pier45 commented Jul 27, 2026

Copy link
Copy Markdown

Adds Monte Carlo Dropout-based uncertainty quantification (epistemic + aleatoric)
for patch classification models.

TIAToolbox's pretrained classification models (AlexNet, MobileNet, etc.) don't
expose uncertainty estimates, only point predictions. This adds a lightweight,
non-invasive wrapper to enable MC-Dropout sampling and uncertainty decomposition.

  • bayesian_wrapper.py: wraps any model, injects dropout at inference if needed
  • mc_dropout.py: runs N stochastic forward passes
  • uncertainty.py: computes epistemic/aleatoric/total uncertainty
  • Includes unit tests

@shaneahmed
shaneahmed requested a review from measty July 27, 2026 09:13
@shaneahmed shaneahmed added this to the Release v2.2.0 milestone Jul 27, 2026
@shaneahmed shaneahmed added the enhancement New feature or request label Jul 27, 2026
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.82353% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.73%. Comparing base (9a27bbb) to head (d644b7b).

Files with missing lines Patch % Lines
tiatoolbox/models/architecture/bayesian_wrapper.py 72.09% 11 Missing and 1 partial ⚠️
tiatoolbox/models/engine/mc_dropout.py 81.81% 4 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1104      +/-   ##
===========================================
- Coverage    99.88%   99.73%   -0.16%     
===========================================
  Files           86       89       +3     
  Lines        11670    11755      +85     
  Branches      1533     1544      +11     
===========================================
+ Hits         11657    11724      +67     
- Misses           7       22      +15     
- Partials         6        9       +3     

☔ 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.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants