Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An Evidence-Based Post-Hoc Adjustment Framework for Anomaly Detection Under Data Contamination

This is the official repository for our paper.

An Evidence-Based Post-Hoc Adjustment Framework for Anomaly Detection Under Data Contamination
Anonymous Authors
Under review. Do not distribute.

[Paper]

Overview

Unsupervised anomaly detection (AD) methods often assume anomaly-free training data, but real-world datasets frequently contain undetected or mislabeled anomalies, degrading performance. Existing AD methods require modifying training pipelines or knowing the anomaly proportion, limiting their use, especially with modern proprietary pre-trained models. To address this, we propose a new framework that refines a pre-trained AD model’s outputs using evidence computed at inference time without accessing the original training data or pipeline. Evidence can be derived from foundation models like CLIP or classical AD methods such as the Latent Outlier Factor. Our framework prevents overfitting by operating label-free at inference and is adaptable across AD methods and data types. Experiments on synthetic, image, and tabular datasets demonstrate its effectiveness in handling contamination and improving AD performance. An ablation study further explores hyperparameter influence and robustness to varying contamination levels.

EPHAD

Figure shows DeepSVDD trained on 2D synthetic contaminated training data with different configurations: (I) Supervised AD with ground truth labels for reference, (ii) Blind considering all samples as normal, (iii) Refine filtering out a fraction of the anomalies, and (iv) EPHAD updating the Blind anomaly detector using evidence computed on test samples during inference.

Installation

This code is written in Python 3.10.4. Running the code requires the packages listed in requirements.txt. To set up a virtual environment using virtualenv:

    cd <path-to-cloned-directory>
    mkdir ~/my_venv
    python -m virtualenv --system-site-packages ~/my_venv
    source ~/my_venv/bin/activate
    pip install -r requirements.txt

To run the code in ADBench the packages listed in ADBench/requirements.txt are required. To set up a virtual environment using virtualenv:

    cd <path-to-cloned-directory>/ADBench
    mkdir ~/my_venv_adtab
    python -m virtualenv --system-site-packages ~/my_venv_adtab
    source ~/my_venv_adtab/bin/activate
    pip install -r requirements.txt

Running experiments with EPHAD

Experiments with tabular datasets

To train and compute the performance metric execute the following steps:

    cd <path-to-cloned-directory>/ADBench
    source ~/my_venv_adtab/bin/activate
    python tabularExp.py

Experiments with image datasets

  • [STEP 1] Run the baselines AD methods and save the scores.

    • Image-based AD baselines using Anomalib

      Run the command and replace $# with corresponding values (see below):

          cd <path-to-cloned-directory>/AD_testbed
          python train.py --config anomalib/models/${model-name}/config/${config-file}
      

      config-file:

      • create and select the config file in within the method folder

      model-name:

      • cflow; draem; fastflow; padim; patchcore; reverse_distillation; ulsad
    • Latent Outlier Exposure

      • (a) Extract image features
          cd <path-to-cloned-directory>/LatentOE-AD
          source ~/my_venv/bin/activate
          python Extract_semantic_features.py
          python Extract_sensory_features.py
      
      • (b) Run following commands and replace $# with corresponding values (see below):
          cd <path-to-cloned-directory>/LatentOE-AD
          source ~/my_venv/bin/activate
          python Launch_Exps.py --config-file $1 --dataset-name $2  --contamination $3
      

      config-file:

      • select the corresponding config file in config_files, e.g.: config_cifar10_blind.yml

      dataset-name:

      • cifar10; fmnist; mnist; mpdd; mvtec; visa; svhn

      contamination:

      • The ground-truth contamination ratio of the dataset. The default ratio is 0.1.
  • [STEP 2] Run CLIP to comnpute the evidence

    • (a) For semantic datasets (cifar10; fmnist; mnist; svhn) run the following commands and replace $# with corresponding values (see below):

          cd <path-to-cloned-directory>/CLIP
          source ~/my_venv/bin/activate
          python zeroshotAD_sem.py --dataset $1
      

      dataset:

      • specify the path of the dataset
    • (b) For sensory datasets (mpdd; mvtec; visa) run the following commands and replace $# with corresponding values (see below):

          cd <path-to-cloned-directory>/CLIP
          source ~/my_venv/bin/activate
          python zeroshotAD.py --dataset $1
      

      dataset:

      • specify the path of the dataset
  • [STEP 3] Run EPHAD and compute the results

    • (a) For baselines run using Anomalib, run the the following commands
        cd <path-to-cloned-directory>/CLIP
        source ~/my_venv/bin/activate
        python compute_scores.py --alpha 0.5
    
    • (b) For LOE, run the the following commands
        cd <path-to-cloned-directory>/CLIP
        source ~/my_venv/bin/activate
        python compute_scores_loe.py --alpha 0.5
    

Acknowledgement

Our code builds on ADBench, Anomalib, LOE and CLIP. We thank them for open sourcing their code.

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages