Training and Evaluation
Use this sub-skill when the user needs to configure, explain, or debug Anomalib's training/evaluation loop, metric collection, callback order, preprocessing/postprocessing, experiment logging, or visualization.
Read first
references/engine-and-metrics.md
references/callbacks-and-logging.md
references/troubleshooting.md
scripts/training-modes.py
scripts/evaluation-smoke.py
Safe operating boundary
Owns the core training/evaluation surface under:
src/anomalib/engine
src/anomalib/callbacks
src/anomalib/metrics
src/anomalib/pre_processing
src/anomalib/post_processing
src/anomalib/loggers
src/anomalib/visualization
Covers:
Engine.fit, Engine.train, Engine.validate, Engine.test, Engine.predict, Engine.from_config
AnomalibModule.configure_callbacks
get_callbacks
Evaluator, AnomalibMetric, PostProcessor, PreProcessor, ImageVisualizer
- training-mode guidance such as
barebones, checkpointing, and validation-first zero/few-shot behavior
Excludes:
- CLI parsing details
- export/deployment internals
- pipeline orchestration
Treat optional logger packages and GPU-only device checks as non-blocking.
Quick routing
| User need |
Do this |
| "How do I wire training, validation, and test?" |
Read references/engine-and-metrics.md. |
| "Why do my callbacks or loggers behave strangely?" |
Read references/callbacks-and-logging.md. |
| "Why are metrics missing, duplicated, or empty?" |
Read references/troubleshooting.md. |
| "Can I run a CPU-only smoke for barebones mode?" |
Run scripts/training-modes.py. |
| "Can I sanity-check metrics, preprocessing, postprocessing, and visualization?" |
Run scripts/evaluation-smoke.py. |
Operating notes
- Model components are usually chained as
pre_processor -> model -> post_processor, with evaluator and visualizer attached as callbacks.
- Validation populates normalization and threshold state for
PostProcessor and related metrics.
- The default evaluator uses prefixed image/pixel metrics so image-level and pixel-level results do not collide.
- Barebones mode removes Lightning logging overhead; use Anomalib's evaluator if you still need returned metrics.
1---2name: training-and-evaluation-23description: "Use for Anomalib's Engine fit/train/test/validate flow, metrics,4 callbacks, preprocessing, postprocessing, loggers, visualization, and5 training-mode guidance while keeping CLI and deployment internals out of6 scope."7metadata:8 source: https://skillmd.com/skills/vectorspacelab/training-and-evaluation-29 disco-role: operating10disable-model-invocation: true11license: Apache 2.012---1314# Training and Evaluation1516Use this sub-skill when the user needs to configure, explain, or debug Anomalib's training/evaluation loop, metric collection, callback order, preprocessing/postprocessing, experiment logging, or visualization.1718## Read first1920- `references/engine-and-metrics.md`21- `references/callbacks-and-logging.md`22- `references/troubleshooting.md`23- `scripts/training-modes.py`24- `scripts/evaluation-smoke.py`2526## Safe operating boundary2728Owns the core training/evaluation surface under:2930- `src/anomalib/engine`31- `src/anomalib/callbacks`32- `src/anomalib/metrics`33- `src/anomalib/pre_processing`34- `src/anomalib/post_processing`35- `src/anomalib/loggers`36- `src/anomalib/visualization`3738Covers:3940- `Engine.fit`, `Engine.train`, `Engine.validate`, `Engine.test`, `Engine.predict`, `Engine.from_config`41- `AnomalibModule.configure_callbacks`42- `get_callbacks`43- `Evaluator`, `AnomalibMetric`, `PostProcessor`, `PreProcessor`, `ImageVisualizer`44- training-mode guidance such as `barebones`, checkpointing, and validation-first zero/few-shot behavior4546Excludes:4748- CLI parsing details49- export/deployment internals50- pipeline orchestration5152Treat optional logger packages and GPU-only device checks as non-blocking.5354## Quick routing5556| User need | Do this |57| --- | --- |58| "How do I wire training, validation, and test?" | Read `references/engine-and-metrics.md`. |59| "Why do my callbacks or loggers behave strangely?" | Read `references/callbacks-and-logging.md`. |60| "Why are metrics missing, duplicated, or empty?" | Read `references/troubleshooting.md`. |61| "Can I run a CPU-only smoke for barebones mode?" | Run `scripts/training-modes.py`. |62| "Can I sanity-check metrics, preprocessing, postprocessing, and visualization?" | Run `scripts/evaluation-smoke.py`. |6364## Operating notes6566- Model components are usually chained as `pre_processor -> model -> post_processor`, with `evaluator` and `visualizer` attached as callbacks.67- Validation populates normalization and threshold state for `PostProcessor` and related metrics.68- The default evaluator uses prefixed image/pixel metrics so image-level and pixel-level results do not collide.69- Barebones mode removes Lightning logging overhead; use Anomalib's evaluator if you still need returned metrics.