Code Monkey home page Code Monkey logo

koriavinash1 / bioexp Goto Github PK

View Code? Open in Web Editor NEW
28.0 6.0 5.0 555.3 MB

Explainability of Deep Learning Models

License: MIT License

Python 64.73% Shell 0.09% Makefile 0.22% CSS 5.69% JavaScript 24.62% HTML 4.38% Batchfile 0.27%
explainable-ai causal-inference causality dissection ablation rct intervention uncertainty activation-maximization gradcam clustering interpretability explainability concept-extraction joint-analysis interpretable-ai

bioexp's Introduction

BioExp

Build Status Documentation Status PyPI version Downloads arXiv arXiv License: MIT

Explaining Deep Learning Models which perform various image processing tasks in the medical images and natural images.

Features

  • Dissection Analysis
  • Ablation Analysis
  • Uncertainity Analysis
    • Epistemic Uncertainty using Bayesian Dropout
    • Aleatoric Uncertainty using Test Time Augmentation
  • Activation Maximization
  • CAM Analysis
  • RCT on input and concept space
  • Concept generation clustering analysis
    • wts based clustering
    • feature based clustering
  • Concept Identification
    • Dissection based
    • Flow based
  • Causal Graph
  • Inference Methods
  • Counterfactuals on Visual Trails
  • Counterfactual Generation
  • Ante-hoc methods (Meta-Causation)

Citations

If you use BioExp, please cite the following papers:

@article{kori2020abstracting,
  title={Abstracting Deep Neural Networks into Concept Graphs for Concept Level Interpretability},
  author={Kori, Avinash and Natekar, Parth and Krishnamurthi, Ganapathy and Srinivasan, Balaji},
  journal={arXiv preprint arXiv:2008.06457},
  year={2020}
}

@article{natekar2020demystifying,
  title={Demystifying Brain Tumor Segmentation Networks: Interpretability and Uncertainty Analysis},
  author={Natekar, Parth and Kori, Avinash and Krishnamurthi, Ganapathy},
  journal={Frontiers in Computational Neuroscience},
  volume={14},
  pages={6},
  year={2020},
  publisher={Frontiers}
}

Defined Pipeline

pipeline

Installation

Running of the explainability pipeline requires a GPU and several deep learning modules.

Requirements

  • 'pandas'
  • 'numpy'
  • 'scipy==1.6.0'
  • 'matplotlib'
  • 'pillow'
  • 'simpleITK'
  • 'opencv-python'
  • 'tensorflow-gpu==1.14'
  • 'keras'
  • 'keras-vis'
  • 'lucid'

The following command will install only the dependencies listed above.

pip install BioExp

Ablation

Usage

from BioExp.spatial import Ablation

A = spatial.Ablation(model = model, 
				weights_pth = weights_path, 
				metric      = dice_label_coef, 
				layer_name  = layer_name, 
				test_image  = test_image, 
				gt 	    = gt, 
				classes     = infoclasses, 
				nclasses    = 4)

df = A.ablate_filter(step = 1)

Dissection

Usage

from BioExp.spatial import Dissector

layer_name = 'conv2d_3'
infoclasses = {}
for i in range(1): infoclasses['class_'+str(i)] = (i,)
infoclasses['whole'] = (1,2,3)

dissector = Dissector(model=model,
                        layer_name = layer_name)

threshold_maps = dissector.get_threshold_maps(dataset_path = data_root_path,
                                                save_path  = savepath,
                                                percentile = 85)
dissector.apply_threshold(image, threshold_maps, 
                        nfeatures =9, 
                        save_path = savepath, 
                        ROI       = ROI)

dissector.quantify_gt_features(image, gt, 
                        threshold_maps, 
                        nclasses   = infoclass, 
                        nfeatures  = 9, 
                        save_path  = savepath,
                        save_fmaps = False, 
                        ROI        = ROI)

Results

dissection

GradCAM

Usage

from BioExp.spatial import cam

dice = flow.cam(model, img, gt, 
				nclasses = nclasses, 
				save_path = save_path, 
				layer_idx = -1, 
				threshol = 0.5,
				modifier = 'guided')

Results

gradcam

Activation Maximization

Usage

from BioExp.concept.feature import Feature_Visualizer

class Load_Model(Model):

  model_path = '../../saved_models/model_flair_scaled/model.pb'
  image_shape = [None, 1, 240, 240]
  image_value_range = (0, 10)
  input_name = 'input_1'

E = Feature_Visualizer(Load_Model, savepath = '../results/', regularizer_params={'L1':1e-3, 'rotate':8})
a = E.run(layer = 'conv2d_17', class_ = 'None', channel = 95, transforms=True)

##Activation Results lucid

Uncertainty

Usage

from BioExp.uncertainty import uncertainty

D = uncertainty(test_image)
            
# for aleatoric
mean, var = D.aleatoric(model, iterations = 50)

# for epistemic
mean, var = D.epistemic(model, iterations = 50)
 
# for combined
mean, var = D.combined(model, iterations = 50)

Results

un

Radiomics

Usage

from BioExp.helpers import radfeatures
feat_extractor = radfeatures.ExtractRadiomicFeatures(image, mask, save_path = pth)
df = feat_extractor.all_features()

Causal Inference Pipeline

un

Contact

bioexp's People

Contributors

koriavinash1 avatar parthnatekar avatar zsfvishnu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

bioexp's Issues

Counterfactual on trails

To understand the effectiveness of visual trails, conduct counterfactual analysis on the concept trails by altering 1st order statistics.
This provides the effectiveness of a particular concept in a trail and a whole trail in general.

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.