A method to generate counterfactuals
Project description
Latent Shift - A Simple Autoencoder Approach to Counterfactual Generation
The idea
Read the paper: https://arxiv.org/abs/2102.09475
Watch a video: https://www.youtube.com/watch?v=1fxSDP8DheI
The main diagram:
Animations/GIFs
Smiling | Arched Eyebrows |
---|---|
Mouth Slightly Open | Young |
---|---|
Generating a transition sequence
For a predicting of smiling
Multiple different targets
Comparison to traditional methods
For a predicting of pointy_nose
Getting Started
# Load classifier and autoencoder
model = classifiers.FaceAttribute()
ae = autoencoders.Transformer(weights="celeba")
# 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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
latentshift-0.0.4.tar.gz
(9.4 kB
view hashes)
Built Distribution
Close
Hashes for latentshift-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8474cfd87e15e6484401b639629fe4370a40640c6f71a21d4a1fb3bbe1100de7 |
|
MD5 | 6dd32297ce68e2bba15304a1e59ca1f0 |
|
BLAKE2b-256 | 368ec411bd1f6d0bebfa44a10dca350c756216b1e04242d112c0a02f2d781543 |