Overview
PatchCore evaluation computes both image-level and pixel-level anomaly detection performance on test datasets. The evaluation script loads pretrained models and generates comprehensive metrics including AUROC and PRO scores.Evaluation Script
Usebin/load_and_evaluate_patchcore.py to evaluate saved models:
1
Specify output directory
First positional argument:
evaluated_results/IM224_WR50 - where results will be saved2
Configure model loader
Use
patch_core_loader with -p flags to specify model paths for each subdataset3
Configure dataset
Use
dataset command with -d flags to specify which subdatasets to evaluateComplete Evaluation Example
Here’s a complete evaluation script for all MVTec AD categories (from sample_evaluation.sh:1):Evaluation Metrics
The evaluation computes three key metrics for each dataset:Image-Level AUROC
What is AUROC?
What is AUROC?
Area Under the Receiver Operating Characteristic Curve
- Ranges from 0 to 1 (1.0 = perfect)
- Measures discrimination ability across all thresholds
- Robust to class imbalance
- Standard metric for anomaly detection
Pixel-Level AUROC (Full)
Computed on all test images including normal images:Pixel-Level AUROC (Anomaly Only)
Computed only on images containing anomalies:Example Output
During evaluation, you’ll see progress and results like this:The
Inferring... progress bar shows prediction progress. Evaluation metrics are computed after all predictions are complete.Understanding the Evaluation Process
The evaluation pipeline (source:load_and_evaluate_patchcore.py:58):1
Load models and datasets
Iterate through dataset/model pairs, loading one PatchCore model per subdataset
2
Generate predictions
3
Normalize scores
4
Compute metrics
Calculate AUROC for image-level detection and pixel-level localization
5
Save results
Store metrics in CSV format with per-dataset breakdown
Ensemble Evaluation
For ensemble models, predictions from multiple models are aggregated:Results Storage
Evaluation results are saved in the specified output directory:results.csv file contains:
Saving Segmentation Images
To visualize predictions, use the--save_segmentation_images flag:
- Original input image
- Ground truth mask (if available)
- Predicted anomaly heatmap
- Anomaly score
Expected Performance
State-of-the-art pretrained models achieve:Results may vary slightly due to hardware differences and software versions, but should be within 0.1-0.3% of reported values.
Next Steps
Load Models
Learn how to load and initialize saved models
Batch Prediction
Run inference on custom image datasets
