Computer vision
Robustness, OOD, Calibration, and Interpretability
Integrate corruption tests, domain shift, out-of-distribution detection, calibration, uncertainty, interpretability, and behavioral debugging.
By the end you can
- Distinguish corruption robustness, domain shift, adversarial behavior, and out-of-distribution inputs
- Explain calibration and selective prediction for vision systems
- Use interpretability methods as probes rather than proofs
- Build a layered robustness and failure-analysis program
Comparison
Not every unfamiliar image is the same kind of failure
Robustness improves when the test names the shift precisely. Four different failures get filed under one complaint — the model did badly on a strange image — and each has its own test, its own owner and its own repair.
Corruption is the family with a fixed vocabulary, and ImageNet-C supplies it. Hendrycks and Dietterich built the benchmark in 2019. “The ImageNet-C benchmark consists of 15 diverse corruption types applied to validation images of ImageNet”, drawn from four groups: noise, blur, weather and digital. “Each corruption type has five levels of severity”. Four further corruptions — speckle noise, spatter, Gaussian blur and saturate — are held back as validation corruptions, so a method tuned on the first fifteen cannot quietly claim the whole benchmark. Image quality degrades; the label is meant to survive.
Domain shift moves the population, the site or the device, and it carries a measured cost. Pneumonia-screening CNNs trained on 158,323 chest radiographs from three hospital systems reached AUC 0.931 (95% CI 0.927–0.936) inside those hospitals. At the external site the best pooled model fell to 0.815 (95% CI 0.745–0.885, P = 0.001). Zech and colleagues reported the pattern in PLOS Medicine in 2018: “Pneumonia-screening CNNs achieved better internal than external performance in 3 out of 5 natural comparisons”. The mechanism sat in the pixels. From the same paper: “CNNs were able to directly detect hospital system of a radiograph for 99.95% NIH (22,050/22,062) and 99.98% MSH (8,386/8,388) radiographs.” A network that can read the site off the film can predict disease burden by site. That works right up to the moment the site changes.
Out-of-distribution input is different again. The image falls outside the intended semantic or acquisition scope, so the right output may be a rejection rather than a label. That boundary is a product decision, not a fact about the world.
Adversarial input has an author. In 2018 a team of nine put black and white stickers on a real stop sign, under a method they called Robust Physical Perturbations (RP2). Their abstract: “With a perturbation in the form of only black and white stickers, we attack a real stop sign, causing targeted misclassification in 100% of the images obtained in lab settings, and in 84.8% of the captured video frames obtained on a moving vehicle (field test) for the target classifier.” The classifiers attacked were LISA-CNN, 91% accurate on the LISA test set, and GTSRB-CNN, 95.7% on GTSRB. NIST's adversarial machine learning taxonomy files the same work under “Physically realizable attacks”: “The attack is applied to evade a road sign detection classifier by physically applying black and white stickers to the road signs.” Severity levels do not describe that attacker. No amount of blur testing anticipates him.
Corruption
The underlying task remains while image quality degrades.
- Blur, noise, weather, compression
- Severity can be controlled
- Label usually preserved
- Example: ImageNet-C style tests
Domain shift
Population, site, device, style, or context changes.
- Labels may keep meaning
- Cues and prevalence change
- External data needed
- Example: new hospital
Out of distribution
The input falls outside the intended semantic or acquisition scope.
- May require rejection
- Definition is task-dependent
- Unknown classes possible
- Example: animal in product scanner
Adversarial or malicious input
An actor intentionally manipulates pixels, objects, or the pipeline.
- Threat model required
- Physical and digital paths differ
- Security controls matter
- Example: patched sign
Confidence should match observed correctness under a declared event
If predictions assigned 80% confidence are correct about 80% of the time, they are calibrated for that population and event. Calibration can change across classes, sites, thresholds and shifts. A softmax maximum is not automatically the probability that the product got it right.
Modern networks do not arrive calibrated. Guo and colleagues measured that across architectures in 2017, and their finding is that “modern neural networks, unlike those from a decade ago, are poorly calibrated”. The causes are ordinary architecture decisions rather than exotic ones: they report that “depth, width, weight decay, and Batch Normalization are important factors influencing calibration”. Nothing in a training run pushes the confidence number toward honesty on its own.
Then hold that against deployment. Ovadia and colleagues benchmarked the standard predictive-uncertainty methods under dataset shift in 2019 and concluded: “We find that traditional post-hoc calibration does indeed fall short, as do several other previous methods. However, some methods that marginalize over models give surprisingly strong results across a broad spectrum of tasks.” A calibration curve fitted on the validation split is a statement about the validation split. Recheck it under deployment conditions, or do not quote it there.
Calibration is conditional evidence, not a permanent property of a model.
Visual
Robustness is a layered system property
No single score or detector covers all failures. Robustness is assembled in layers, each with an owner.
Input controls come first: quality checks, sensor validation, format constraints and provenance. It is the cheapest place to stop an image the model was never meant to see. Model evidence is the second layer — task performance, uncertainty, calibration and sensitivity to shift, measured on data that fitted nothing.
The third layer is decision policy, where thresholds, abstention, fallback and rate limits live, and it has a cleared precedent. The FDA authorised IDx-DR on 11 April 2018 as the first autonomous AI diagnostic device. It does not only report more than mild DR (mtmDR) detected or not detected. Insufficient image quality is a third output the device is authorised to give. In the pivotal trial, 900 enrolled participants at 10 primary care sites, 38 of them — 4% — received it. Abstention there is a designed output with a regulatory record behind it, not a cut-off improvised on top of a score.
Human workflow is the fourth layer: review interfaces, escalation, contestation, incident response. It absorbs whatever the third layer declines, so it has to be sized for that traffic before the threshold is set. Monitoring and update closes the loop with drift detection, label collection, retraining gates and rollback.
- 01
Input controls
Quality checks, sensor validation, format constraints, and provenance.
- 02
Model evidence
Task performance, uncertainty, calibration, and shift sensitivity.
- 03
Decision policy
Thresholds, abstention, fallback, and rate limits.
- 04
Human workflow
Review interfaces, escalation, contestation, and incident response.
- 05
Monitoring and update
Drift detection, labels, retraining gates, and rollback.
Analogy
A weather forecast tested against what actually happened
A forecaster says “70% chance of rain” on many comparable days. Calibration asks whether rain occurs on roughly seven out of ten of those days. The test is not applied to a single forecast. It is applied to a population of forecasts that carried the same number.
Rain on a given day is a single event with one outcome. Model outputs may concern classes, boxes, masks or downstream decisions, and each needs its own declared event before the frequency check means anything. Confidence and certainty stay separate all the same.
A calibrated probability can still be wrong on any individual case.
Key idea
An OOD detector cannot define the universe outside your product
Out-of-distribution is relative to a reference dataset, a representation and an intended use. A detector may catch obvious foreign images while missing the subtle shift that actually costs accuracy. And the scope a team declares can leave out an input the world supplies anyway.
On 18 March 2018 in Tempe, Arizona, a vehicle controlled by an Uber ATG developmental automated driving system struck and killed a pedestrian. The system detected her 5.6 seconds before impact. The National Transportation Safety Board's accident report, adopted in November 2019, records what it did with her: “The ADS changed the pedestrian's classification several times, alternating between vehicle, bicycle, and other”. The design “excluded tracking history for nonpersisting objects”, so each change of class restarted her as a brand-new object with no trajectory behind it. The report gives the reason: “The system never classified her as a pedestrian—or correctly predicted her path—because she was crossing N. Mill Avenue at a location without a crosswalk, and the system design did not include consideration for jaywalking pedestrians.”
Nothing about that input was exotic. It was outside the declared scope and inside the operating environment. That is the gap an OOD detector cannot close on its own: the detector enforces a boundary someone else drew.
Evaluate known shifts, unknown classes, near-OOD cases and operational consequences. Write down the input classes your design deliberately excludes and test each one as a named slice. Combine rejection with input validation and monitoring rather than relying on one score.
OOD detection is a risk signal, not a universal border around valid reality.
Example
Interpretability methods reveal different aspects of behavior
Use multiple probes and compare them with controlled interventions. Each method answers a narrow question, and the questions do not overlap as much as the pictures suggest.
- Saliency or gradient map: Highlights sensitivity to local pixel changes, and depends on baseline, smoothing and aggregation choices.
- Grad-CAM: Projects class-related activation through a chosen convolutional layer, so the layer you pick is part of the answer.
- Occlusion test: Measures output change when regions are hidden, which makes it an intervention rather than a visualization.
- Counterfactual edit: Alters an attribute or context while preserving other evidence, testing a stated hypothesis about the decision.
- Prototype or neighbor review: Shows training or reference examples near the representation, which can expose site or device clustering.
- Concept probe: Tests whether a defined attribute is accessible in internal features, not whether the model used it.
Key idea
A heatmap can be stable, plausible, and still misleading
Visual explanations depend on layer, baseline, smoothing, aggregation and model gradients. They may highlight correlated context, or stay unchanged when the decision mechanism changes. Use sanity checks, randomization, perturbation and task-specific hypotheses. Do not treat an attractive overlay as proof of causal reasoning.
The heatmaps themselves went on trial in 2018. Adebayo and colleagues randomized the model weights, then the training labels, and re-ran the saliency methods. Some maps came out essentially unchanged. Their conclusion is that “some existing saliency methods are independent both of the model and of the data generating process”. That is fatal for the work those maps are usually put to, since such methods “are inadequate for tasks that are sensitive to either data or model, such as, finding outliers in the data, explaining the relationship between inputs and outputs that the model learned, and debugging the model”. The authors read them instead “through an analogy with edge detection in images, a technique that requires neither training data nor model”.
That is the test to run before a heatmap is allowed into a review workflow. Randomize what the map claims to depend on, and see whether the map notices.
Interpretability tools generate evidence about behavior; they do not read the model's mind.
Steps
Build a robustness program from anticipated failure to response
Tests should connect to ownership and action. For medical devices that connection is not advice — it is published regulatory text. On 27 October 2021 the FDA, Health Canada and the UK's MHRA jointly published ten Guiding Principles for Good Machine Learning Practice for Medical Device Development. Three of them map directly onto the steps below.
Step 1, enumerate shifts: list devices, environments, populations, corruptions, attacks and unknowns, including the classes you intend to exclude.
Step 2, create controlled suites: vary severity while preserving labels where that is justified, in the ImageNet-C manner.
Step 3, test real transfer. Principle 4, “Training Data Sets Are Independent of Test Sets”, states: “Training and test datasets are selected and maintained to be appropriately independent of one another. All potential sources of dependence, including patient, data acquisition, and site factors, are considered and addressed to assure independence.” Principle 8 goes on to require that performance be demonstrated “independently of the training data set” under clinically relevant conditions. A held-out random split from the same hospitals satisfies neither.
Step 4, tune selective policies: calibrate confidence, abstention, fallback and review capacity together. Measure the abstained slice, not only its size.
Step 5, connect monitoring. Principle 10 reads: “Deployed models have the capability to be monitored in 'real world' use with a focus on maintained or improved safety and performance”, and it names “dataset drift” among the degradation risks to be controlled. Metrics, label collection, alerts, incident playbooks and rollback are what that capability is made of.
1. Enumerate shifts
List devices, environments, populations, corruptions, attacks, and unknowns.
2. Create controlled suites
Vary severity while preserving labels where justified.
3. Test real transfer
Use external sites, future time, and naturally occurring failures.
4. Tune selective policies
Calibrate confidence, abstention, fallback, and review capacity.
5. Connect monitoring
Define metrics, label collection, alerts, incident playbooks, and rollback.
Example
Practice: stress-test a roadside object detector
The detector must work across weather, countries, cameras, night scenes, construction zones and intentional sign modifications. Every item below has a published precedent to copy from.
- Separate the corruption, domain, OOD and adversarial families before writing tests — corruption graded by severity in the ImageNet-C manner with labels preserved, adversarial reproduced under a stated threat model such as RP2's black and white stickers on a real stop sign.
- Define box-level confidence calibration and an abstention or fallback action, then measure the abstained slice the way the IDx-DR record does: 4% of participants rejected, and 10 of those 38 positive. A rejection rate reported without the outcomes of the rejected cases is half a number.
- Create a near-OOD slice with unfamiliar vehicle and sign designs, and add the input classes your design excludes on purpose — the NTSB found the Tempe system's design did not include consideration for jaywalking pedestrians, an exclusion that was never tested as a slice.
- Use one explanation method to form a hypothesis, then test it with an intervention — and run the Adebayo randomization first: a map that survives randomizing the weights and then the labels is not evidence about this model.
- Specify an incident trigger for a newly observed failure cluster, including clusters the pipeline can manufacture itself: the Tempe report records classification alternating between vehicle, bicycle and other, with tracking history discarded at each flip.
Position
A confidence threshold does not tell you when the model does not know
Selective prediction is sold as the answer to the hard case. Set a threshold, abstain below it, escalate to a human. The mechanism is real — it ships inside a cleared medical device — and the reasoning underneath it runs backwards in two separate places.
The first is the number being thresholded. Guo and colleagues found modern networks poorly calibrated and offered a cheap repair: “temperature scaling – a single-parameter variant of Platt Scaling – is surprisingly effective at calibrating predictions”. One parameter, fitted after training, cheap enough to invite the conclusion that calibration is a solved problem. Then read the second result. Ovadia and colleagues benchmarked that same family under dataset shift in 2019 and found that traditional post-hoc calibration does indeed fall short there, while methods that marginalize over models held up better across a broad spectrum of tasks. So the cheap repair is among the methods that fail under shift — and shift is precisely the condition abstention exists to catch. The threshold was tuned on the familiar input and asked to rule on the unfamiliar one. Hendrycks and Dietterich built that limit into their own benchmark by holding four corruptions back, speckle noise, spatter, Gaussian blur and saturate, so that a method tuned on the fifteen could not claim the rest.
The second place is what abstention does with the case it declines. IDx-DR is the cleanest record available, because a regulator counted. The FDA's De Novo summary gives 87.4% observed sensitivity and 89.5% observed specificity with a 96% imageability rate. The published pivotal trial reports “sensitivity of 87.2% (95% CI, 81.8–91.2%), specificity of 90.7% (95% CI, 88.3–92.7%), and imageability rate of 96.1% (95% CI, 94.6–97.3%)” across 900 subjects at 10 primary care sites; Abràmoff and colleagues published it in npj Digital Medicine in 2018. In that trial 38 participants received insufficient image quality instead of a grade. The FDA's summary says what became of them: “In the 38 participants with AI system insufficient image quality, the prevalence of mtmDR was 10/38 (26%), comparable to the mtmDR prevalence in the fully analyzable dataset.” Ten people with the disease left the automated pathway carrying no finding. The device was right to decline them, and the decline changed nothing about their eyes. It moved the risk to whoever was meant to catch them next — a fact invisible in any metric computed on the cases the system accepted.
The usual fallback is the heatmap: if confidence is unreliable, a person will look at the explanation. Adebayo and colleagues randomized the model weights, then the training labels, and some maps came out essentially unchanged — methods “independent both of the model and of the data generating process”, which the authors compare to edge detection.
So an honest selective policy names its population and counts what it rejected. Calibrated here, on this data, at this threshold, with this much review capacity waiting on the other side. Anywhere else the abstention rate is a hypothesis, and testing it takes a labelled sample from the new conditions — including labels for the cases the model refused to touch.
Abstention removed those cases from the model's risk, not from the population's.
Key takeaways
- Corruption, domain shift, OOD inputs and adversarial manipulation need different tests: fifteen ImageNet-C corruptions at five severities, an AUC falling from 0.931 to 0.815 across hospital systems, a declared scope with no consideration for jaywalking pedestrians, and black and white stickers that flipped a real stop sign in 100% of lab images.
- Calibration links confidence to empirical correctness for one population and event. Guo and colleagues found modern networks poorly calibrated, and Ovadia and colleagues found traditional post-hoc calibration falls short under dataset shift.
- Selective prediction trades coverage for safer handling, but the rejected slice is not the easy slice: 10 of IDx-DR's 38 abstained participants (26%) had more than mild DR, comparable to the graded cases.
- OOD detection is relative to intended use and cannot define every future invalid input. The NTSB recorded an automated driving system that detected a pedestrian 5.6 seconds before impact and never classified her as one.
- Interpretability tools are behavioral probes: Adebayo and colleagues showed that some saliency maps survive randomizing both the model weights and the training labels.
- Robustness programs connect controlled tests, external transfer, decision policy, monitoring, incidents and rollback. Principles 4, 8 and 10 of the FDA / Health Canada / MHRA guiding principles of 27 October 2021 state the requirement in regulatory text.