A method to generate counterfactuals
Project description
Latent Shift - A Simple Autoencoder Approach to Counterfactual Generation
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:
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
$pip install latentshift
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)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latentshift-0.0.6.tar.gz.
File metadata
- Download URL: latentshift-0.0.6.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dec6b76952c664619e63d1ab2d03d9c20db6defd64d5db191262cca96bbdde85
|
|
| MD5 |
e8f3c7730417e49a25af5cd12e764de1
|
|
| BLAKE2b-256 |
9336eff50a708b95d33f0f2085efa2cc4041bbef3b9b0d1b297e653d51b5a12f
|
File details
Details for the file latentshift-0.0.6-py3-none-any.whl.
File metadata
- Download URL: latentshift-0.0.6-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc01ff6d8f376c592bf0b294d82e8884611d66d60d7f231d4a3ee8d68c407bff
|
|
| MD5 |
5377202f6d5f2c0f22ddb80c9c3c94c1
|
|
| BLAKE2b-256 |
d4241c1cf43d20708aa2d202d3ee0a99504f2b6891c5aeed145f6fcd39016454
|