Online-InReaCh: Online Inter-Realization Channels for Unsupervised Image Anomaly Detection

January 12, 2026 Β· View on GitHub

Online-InReaCh is the first fully unsupervised, online anomaly detection and localization method that dynamically adapts to non-stationary image distributions. Unlike prior methods, it does not require a fixed, curated, and purely nominal training set or supervision β€” it builds and updates its nominal model on-the-fly during inference.


πŸ” Paper Summary

"We propose Online-InReaCh, the first fully unsupervised on- line method for detecting and localizing anomalies on-the-fly in image sequences while following non-stationary distributions. Previous anomaly detection methods are limited to supervised one-class classification or are unsupervised but still pre-compute their nominal model. Online-InReaCh can operate online by dynamically maintaining a nominal model of commonly occurring patches that associate well across image realizations of the underlying nominal distribution while removing stale previously nominal patches. Online-InReaCh, while competitive in previous offline benchmarks, also achieves 0.936 and 0.961 image- and pixel-wise AUROC when tested online on MVTecAD, where 23.8% of all randomly sampled images contain anomalies. Online-InReaCh’s performance did not correlate with anomaly proportion even to 33.5%. We also show that Online-InReaCh can integrate new nominal structures and distinguish anomalies after a single frame, even in the worst-case distribution shift from one training class to a new previously unseen testing class."

πŸ“° Title: Unsupervised, Online and On-The-Fly Anomaly Detection for Non-Stationary Image Distributions

πŸ“š Authors: Declan McIntosh, Alexandra Branzan Albu

πŸ“„ PDF: View Paper


✨ Key Features

  • βœ… Fully unsupervised β€” no curated nominal training set needed
  • πŸ”„ Online updates β€” adapts model in real time with no re-training
  • 🌩️ Handles non-stationary data β€” robust to domain and distribution shifts
  • πŸ” Supports on-the-fly inference β€” per-frame predictions in streamed data
  • πŸš€ Competitive with state-of-the-art methods like SoftPatch and PatchCore in offline setting

πŸ—οΈ Code Structure

β”œβ”€β”€ OnlineInReaCh.py         # Main class for online anomaly detection
β”œβ”€β”€ FeatureDescriptors.py    # Feature extraction using Wide-ResNet50 (required)
β”œβ”€β”€ model.py, utils.py       # Supporting modules (required)
β”œβ”€β”€ mvtec_loader.py          # MVTec dataset loader with corruption support
β”œβ”€β”€ qual/                    # Output directory for qualitative results
β”œβ”€β”€ Experiments/             # Saved results and config logs

πŸš€ Getting Started

1. Install Dependencies

pip install torch torchvision scikit-learn numpy opencv-python faiss-gpu tqdm

βœ… Requires CUDA β‰₯ 10.2 for full determinism

2. Run Optimal Online Detection on MVTec

python OnlineInReaCh.py -ttl 40 -minl 2 -seed 0 -data_dir data/MVTecAD/ -n DEMO_RUN"

This runs Online-InReaCh with:

  • Time-to-Live = 40
  • Min Channel Length = 2
  • Seed = 0
  • Dataset path: data/MVTecAD/

3. Custom Run

python OnlineInReaCh.py \
    -ttl 20 \
    -minl 2 \
    -seed 0 \
    -data_dir data/MVTecAD/ \
    -n my_experiment_name
ArgumentTypeDescription
-ttlintTime-to-live for channels (e.g., 40)
-minlintMinimum channel length (e.g., 2)
-seedintRandom seed (e.g., 112358)
-data_dirstrPath to the dataset root (e.g., data/MVTecAD/)
-nstrName of the experiment for saved results and output (e.g., my_run_name)
-corr (opt)intNumber of corrupted images to inject (default: 0 or unused)
-tur (opt)intTest update rate β€” controls update frequency after training (default: 1)

πŸ“Š Results (Online Setting)

This code has been significantly refactored since the original publication. The results from this code-base exceeds the reported online results for MvTec AD, seen below.

DatasetImage AUROCPixel AUROC
MvTec AD0.9420.964

The above is gained with the following configuration.

python OnlineInReaCh.py \
    -ttl 40 \
    -minl 2 \
    -seed 0 \
    -data_dir data/MVTecAD/ \
    -n my_experiment_name

Full results and logs are saved in Experiments/<commit_hash>/<seed>/<experiment_name>/.


πŸ“Έ Visualizations

Output confidence maps are saved to:

qual/<experiment_name>/<class_name>/

πŸ“ Dataset Format

Each class directory should follow the MvTec AD format and contain:

data/MVTecAD/
└── class_name_here/
    β”œβ”€β”€ ground_truth/
    β”‚   └── test/
    β”‚       └── corruption_type/
    β”‚           β”œβ”€β”€ 000.png        # Binary mask (0 = nominal, 255 = anomaly)
    β”‚           └── ...
    β”œβ”€β”€ test/
    β”‚   └── good/
    β”‚       β”œβ”€β”€ 000.png            # Test image without anomaly or corresponding gt mask
    β”‚       └── ...
    β”‚   └── corruption_type/
    β”‚       β”œβ”€β”€ 000.png            # Test image with anomaly
    β”‚       └── ...
    β”œβ”€β”€ train/
        └── good/
            β”œβ”€β”€ 000.png            # Nominal training image
            └── ...

πŸ“˜ Citation

If you find this work useful, please cite:

@inproceedings{mcintosh2024onlineinreach,
  title={Unsupervised, Online and On-The-Fly Anomaly Detection For Non-Stationary Image Distributions},
  author={Declan McIntosh and Alexandra Branzan Albu},
  booktitle={European Conference on Computer Vision (ECCV)},
  year={2024}
}

and

@inproceedings{mcintoshInReaCh,
      title={Inter-Realization Channels: Unsupervised Anomaly Detection in Images Beyond One-Class Classification},
      author={Declan McIntosh and Alexandra Branzan Albu},
      year={2023},
      booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
      month     = {October}
}

πŸ› οΈ TODO

  • Nothing at the Moment!