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)
Metadata
Release files for latentshift 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latentshift-0.0.6.tar.gz | 19.8 kB | Without provenance | Details for latentshift-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latentshift-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for latentshift-0.0.6-py3-none-any.whl |
Total release size: 41.5 kB
Release files / latentshift-0.0.6.tar.gz
| Download URL | latentshift-0.0.6.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dec6b76952c664619e63d1ab2d03d9c20db6defd64d5db191262cca96bbdde85
|
|
BLAKE2b-256 checksum How to use checksums |
9336eff50a708b95d33f0f2085efa2cc4041bbef3b9b0d1b297e653d51b5a12f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Release files / latentshift-0.0.6-py3-none-any.whl
| Download URL | latentshift-0.0.6-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc01ff6d8f376c592bf0b294d82e8884611d66d60d7f231d4a3ee8d68c407bff
|
|
BLAKE2b-256 checksum How to use checksums |
d4241c1cf43d20708aa2d202d3ee0a99504f2b6891c5aeed145f6fcd39016454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.1
|
Security for latentshift 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.