Code Monkey home page Code Monkey logo

dif-fuse's Introduction

Dif-fuse

Work-in-progress Pytorch repository for the paper “Diffusion Models for Counterfactual Generation and Anomaly Detection in Brain Images”. An official version will be released soon.

To pre-process BraTS data, after placing the nifti files in the folder data/brats2021, you can run:

python scripts/brats-preprocess.py 

To train a diffusion model on healthy samples:

python scripts/image_train.py 

To train an autoencoder to reconstruct the images:

python scripts/train_autoencoder.py -filepath_to_arguments_json_config scripts/baseline.json --experiment_name autoencoder

To train a baseline classifier to classify the images:

python scripts/train_baseline_classifier.py -filepath_to_arguments_json_config scripts/baseline.json --experiment_name baseline_classifier

To generate the saliency maps with ACAT (Adversarial Counterfactual Attention), employing the classifier and autoencoder trained in the previous steps:

python scripts/saliency_maps.py -filepath_to_arguments_json_config scripts/baseline.json --experiment_name create_saliency

To generate healthy samples with Dif-fuse, you can run the following code, making sure to set the correct path to the model that you wish to use:

python scripts/image_sample_dif-fuse.py --model_path results/test/model054000.pt 

dif-fuse's People

Contributors

nickarafyllis avatar alessandro-f avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.