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.3.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file latentshift-0.0.3.tar.gz
.
File metadata
- Download URL: latentshift-0.0.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9b450146f6c35d04c5b13a16d5fd9a702b6a3c7e7ad3146c615b7cdbfd37f00 |
|
MD5 | 129e5b6fa323dc54d18f1752eaac3604 |
|
BLAKE2b-256 | 82a45328602573419f1a1648299939c8c6cb46e08083c070e419d16ca6f8a2b7 |
File details
Details for the file latentshift-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: latentshift-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95ef0cd535099b67525b5e4140132a7f4ebcf91f283e73952183935fe1156110 |
|
MD5 | ed6c05e5ee7b646bd96dc8e85782e1d8 |
|
BLAKE2b-256 | 55bf3017db9b3f676ef6fdf3c13183d705411eb4cac12e11bea0307123087b91 |