A library for segmentation model explainability through sensitivity analysis
Project description
Model Interpretation through Sensitivity Analysis for Segmentation
Interpret and explain your segmetation models through analysing their sensitivity to defined alterations of the input
Input alterations currently include:
- rotation
- cropping
Install
pip install misas
How to use
Example with kaggle data
from fastai.vision import *
from misas.core import default_cmap
#hide_output
img = lambda: open_image("example/kaggle/images/1-frame014-slice005.png")
trueMask = lambda: open_mask("example/kaggle/masks/1-frame014-slice005.png")
trainedModel = Fastai1_model('chfc-cmi/cmr-seg-tl', 'cmr_seg_base')
fig, ax = plt.subplots(figsize=(8,8))
img().show(ax=ax)
trueMask().show(ax=ax, cmap=default_cmap)
Rotation
plot_series(get_rotation_series(img(), trainedModel))
results = eval_rotation_series(img(), trueMask(), trainedModel)
plt.plot(results['deg'], results['c1'])
plt.plot(results['deg'], results['c2'])
plt.axis([0,360,0,1])
(0.0, 360.0, 0.0, 1.0)
You can use interactive elements to manually explore the impact of rotation
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
rotation_series = get_rotation_series(img(),trainedModel,step=10)
def plot_rotation_frame(deg):
return plot_frame(*rotation_series[int(deg/10)], figsize=(10,10))
#hide_output
interact(
plot_rotation_frame,
deg=widgets.IntSlider(min=0, max=360, step=10, value=90, continuous_update=False)
)
There are lots of other transformations to try (e.g. cropping, brightness, contrast, ...) as well as MR specific artifacts.
Overview
This is the schematic overview of how misas
works. Created with the amazing Excalidraw.
Logo
The logo was designed by Markus J. Ankenbrand using:
- Open box / Boite ouverte by SimpleIcons via openclipart.org
- Cutter icon by SimpleIcons via openclipart.org, original by Marco Olgio, via WikiMedia
- Hack Font
- Inkscape
Attribution
This project is inspired by the awesome "Is it a Duck or Rabbit" tweet by @minimaxir. Also check out the corresponding repo.
%%html
<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Is it a Duck or a Rabbit? For Google Cloud Vision, it depends how the image is rotated. <a href="https://t.co/a30VzjEXVv">pic.twitter.com/a30VzjEXVv</a></p>— Max Woolf (@minimaxir) <a href="https://twitter.com/minimaxir/status/1103676561809539072?ref_src=twsrc%5Etfw">March 7, 2019</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>Is it a Duck or a Rabbit? For Google Cloud Vision, it depends how the image is rotated. pic.twitter.com/a30VzjEXVv
— Max Woolf (@minimaxir) March 7, 2019
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.