latentshift

A method to generate counterfactuals

https://github.com/ieee8023/latentshift

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.5%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

A method to generate counterfactuals

Basic Info
  • Host: GitHub
  • Owner: ieee8023
  • License: other
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage:
  • Size: 16 MB
Statistics
  • Stars: 12
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 2
Created over 3 years ago · Last pushed 12 months ago
Metadata Files
Readme License Citation

README.md

Latent Shift - A Simple Autoencoder Approach to Counterfactual Generation

Open In Colab

The idea

Read the paper about Latent Shift: https://arxiv.org/abs/2102.09475

Watch a video: https://www.youtube.com/watch?v=1fxSDP8DheI

Read the paper about Counterfactual Alignment: https://arxiv.org/abs/2312.02186

The main diagram: latentshift.gif

Animations/GIFs

| Smiling | Arched Eyebrows| | ----------- | ----------- | | | |

|Mouth Slightly Open | Young | | ----------- | ----------- | | | |

Generating a transition sequence

For a predicting of smiling

gen_sequence.png

Multiple different targets

Comparison to traditional methods

For a predicting of pointy_nose

comparison.png

Getting Started

bash $pip install latentshift `

```python3 import latentshift

Load classifier and autoencoder

model = latentshift.classifiers.FaceAttribute(download=True) ae = latentshift.autoencoders.VQGAN(weights="faceshq", download=True)

Load image

input = torch.randn(1, 3, 1024, 1024)

Defining Latent Shift module

attr = captum.attr.LatentShift(model, ae)

Computes counterfactual for class 3.

output = attr.attribute(input, target=3) ```

Owner

  • Name: Joseph Paul Cohen
  • Login: ieee8023
  • Kind: user

Amazon, Butterfly Network, Stanford AIMI, Mila, Director: Institute for Reproducible Research, MLMed.org, AcademicTorrents.com, ShortScience.org

Citation (CITATION)

@article{cohen2021gif,
title = {{Gifsplanation via Latent Shift: A Simple Autoencoder Approach to Counterfactual Generation for Chest X-rays}},
author = {Cohen, Joseph Paul and Brooks, Rupert and En, Sovann and Zucker, Evan and Pareek, Anuj and Lungren, Matthew P. and Chaudhari, Akshay},
journal = {Medical Imaging with Deep Learning},
url = {https://arxiv.org/abs/2102.09475},
year = {2021}
}

GitHub Events

Total
  • Release event: 1
  • Watch event: 3
  • Push event: 4
  • Pull request event: 2
  • Create event: 2
Last Year
  • Release event: 1
  • Watch event: 3
  • Push event: 4
  • Pull request event: 2
  • Create event: 2

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: less than a minute
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ieee8023 (1)
Pull Request Authors
  • ieee8023 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 182 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 6
  • Total maintainers: 1
pypi.org: latentshift

A method to generate counterfactuals

  • Versions: 6
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 182 Last month
Rankings
Dependent packages count: 7.5%
Stargazers count: 21.8%
Forks count: 23.0%
Average: 30.5%
Dependent repos count: 69.6%
Maintainers (1)
Last synced: 12 months ago