/MADDR_code

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

A Model-Agnostic Framework for Universal Anomalym Detection of Multi-Organ and Multi-Modal Images — Pytorch Implementation

This is the official implementation of "A Model-Agnostic Framework for Universal Anomalym Detection of Multi-Organ and Multi-Modal Images". It includes experiments reported in the paper. The framework we propose can be applied to classic anomaly detection algorithms. Here we take our framework applied to DPA as an example to show the operation of the code. Thanks to the source code provided by the author of DPA.

The structure of project will not be introduced too much here. For details, please refer to the official implementation code introduction of DPA. We mainly introduce our framework code and how to apply our framework to DPA.

MADDR

anomaly_detection - python package; implementations of 
                                MADDR_dpa
                                └───rec_losses.py -- -- We redefine the L1Loss class function, by imposing organ and modality classification constraints along with center constraint on the disentangled latent representation.

Installation

Requirements: Python3.6

You can install miniconda environment(version 4.5.4):

wget https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
bash Miniconda3-4.5.4-Linux-x86_64.sh
export PATH="{miniconda_root/bin}:$PATH

Installation:

pip install -r requirements.txt
pip install -e .

Training and Evaluation

The paper includes experiments on LiTS, COVID-CT and COVID-X-rays datasets.

To reproduce all experiments of the paper, run:

python run_experiments.py

The training process and inference process are consistent with the baseline method, and we keep most parameters the same as the baseline methods, such as optimizer and learning rate.

Data Preprocessing

  1. Download data (1)COVID-CT-link, (2)COVID-Xray-link, (3)COVID-CT-link

  2. Create a train split ("./folds/train_test_split/normal/train")

Training models

You can download the original code of DPA, and then replace "rec_loss.py" file in the DPA code with "rec_loss.py" file we provide. Applying the MADDR framework to other baseline methods does the same.

The official implementation of the baseline method:

  1. DPA
  2. f-AnoGAN
  3. MemAE
  4. GANomaly