Latte: Cross-framework Python Package for Evaluation of Latent-based Generative Models

Overview

Cross-framework Python Package for Evaluation of Latent-based Generative Models

Documentation Status CircleCI codecov CodeFactor License PyPI version DOI arXiv

Latte

Latte (for LATent Tensor Evaluation) is a cross-framework Python package for evaluation of latent-based generative models. Latte supports calculation of disentanglement and controllability metrics in both PyTorch (via TorchMetrics) and TensorFlow.

Installation

For developers working on local clone, cd to the repo and replace latte with .. For example, pip install .[tests]

pip install latte-metrics           # core (numpy only)
pip install latte-metrics[pytorch]  # with torchmetrics wrapper
pip install latte-metrics[keras]    # with tensorflow wrapper
pip install latte-metrics[tests]    # for testing

Running tests locally

pip install .[tests]
pytest tests/ --cov=latte

Example

Functional API

import latte
from latte.functional.disentanglement.mutual_info import mig
import numpy as np

latte.seed(42)

z = np.random.randn(16, 8)
a = np.random.randn(16, 2)

mutual_info_gap = mig(z, a, discrete=False, reg_dim=[4, 3])

Modular API

import latte
from latte.metrics.core.disentanglement import MutualInformationGap
import numpy as np

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update_state(z, attributes)

mig_val = mig.compute()

TorchMetrics API

import latte
from latte.metrics.torch.disentanglement import MutualInformationGap
import torch

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update(z, attributes)

mig_val = mig.compute()

Keras Metric API

import latte
from latte.metrics.keras.disentanglement import MutualInformationGap
from tensorflow import keras as tfk

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update_state(z, attributes)

mig_val = mig.result()

Documentation

https://latte.readthedocs.io/en/latest

Supported metrics

๐Ÿงช Beta support | โœ”๏ธ Stable | ๐Ÿ”จ In Progress | ๐Ÿ•ฃ In Queue | ๐Ÿ‘€ KIV |

Metric Latte Functional Latte Modular TorchMetrics Keras Metric
Disentanglement Metrics
๐Ÿ“ Mutual Information Gap (MIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ??
๐Ÿ“ Dependency-blind Mutual Information Gap (DMIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Dependency-aware Mutual Information Gap (XMIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Dependency-aware Latent Information Gap (DLIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Separate Attribute Predictability (SAP) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Modularity ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ ฮฒ-VAE Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ FactorVAE Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ DCI Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Interventional Robustness Score (IRS) ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Consistency ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Restrictiveness ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
Interpolatability Metrics
๐Ÿ“ Smoothness ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Monotonicity ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Latent Density Ratio ๐Ÿ•ฃ ๐Ÿ•ฃ ๐Ÿ•ฃ ๐Ÿ•ฃ
๐Ÿ“ Linearity ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€

Bundled metric modules

๐Ÿงช Experimental (subject to changes) | โœ”๏ธ Stable | ๐Ÿ”จ In Progress | ๐Ÿ•ฃ In Queue

Metric Bundle Latte Functional Latte Modular TorchMetrics Keras Metric Included
Dependency-aware Disentanglement ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช MIG, DMIG, XMIG, DLIG
LIAD-based Interpolatability ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช Smoothness, Monotonicity

Cite

For individual metrics, please cite the paper according to the link in the ๐Ÿ“ icon in front of each metric.

If you find our package useful please cite our repository and arXiv preprint as

@article{
  watcharasupat2021latte,
  author = {Watcharasupat, Karn N. and Lee, Junyoung and Lerch, Alexander},
  title = {{Latte: Cross-framework Python Package for Evaluation of Latent-based Generative Models}},
  eprint={2112.10638},
  archivePrefix={arXiv},
  primaryClass={cs.LG},
  url = {https://github.com/karnwatcharasupat/latte}
  doi = {10.5281/zenodo.5786402}
}
Comments
  • Documentation: Metric Descriptions

    Documentation: Metric Descriptions

    Might be nice to provide a short description for each metric in addition to the paper links. The readme might get too long with it, but either some doc in the repo or maybe on a github.io page?

    type: documentation priority: high 
    opened by alexanderlerch 2
  • Add Smoothness and Monotonicity support

    Add Smoothness and Monotonicity support

    Smoothness

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    Monotonicity

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add Modularity support

    Add Modularity support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add SAP support

    Add SAP support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add DMIG, DLIG, XMIG support

    Add DMIG, DLIG, XMIG support

    DMIG

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    XMIG

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    DLIG

    • [ x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add MIG support

    Add MIG support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Support issue for on-the-fly computation in TF2 graph mode

    Support issue for on-the-fly computation in TF2 graph mode

    The current delegate-to-NumPy technique used in TF is only compatible with TF2 eager mode since Tensor.numpy() would not work in graph mode. As a result, graph-mode users will only be able to use Latte in the evaluation stage when the model weights are no longer changing but not on-the-fly during the training stage.

    However, certain computation steps required for some metrics (especially MI-based ones) necessarily require scikit-learn ops and there is no (maintainable) way to create consistent TF mirrors of those functions.

    One potential solution is to wrap the core functions in tf.numpy_function or tf.py_function but we will have to figure out a way to make the wrapper less painful to implement/maintain since the variable args/kwargs option currently used by the dtype converter is not allowed in these functions. A naive workaround would be to make a tf.numpy_function wrapper for every highest-possible level function with fixed args but this would be considered a last-resort solution.

    Links:

    • https://www.tensorflow.org/api_docs/python/tf/numpy_function
    • https://www.tensorflow.org/api_docs/python/tf/py_function
    type: enhancement priority: medium !! needs more brains !! 
    opened by karnwatcharasupat 3
Releases(v0.0.1-alpha5)
  • v0.0.1-alpha5(Jan 20, 2022)

    What's Changed

    • Add contributing guide by @karnwatcharasupat in https://github.com/karnwatcharasupat/latte/pull/16
    • [ADD] add example notebooks by @karnwatcharasupat in https://github.com/karnwatcharasupat/latte/pull/18

    Full Changelog: https://github.com/karnwatcharasupat/latte/compare/v0.0.1-alpha3...v0.0.1-alpha5

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1-alpha3(Dec 16, 2021)

  • v0.0.1-alpha2(Dec 9, 2021)

  • v0.0.1-alpha1(Dec 1, 2021)

Owner
Karn Watcharasupat
Lab Cat ๐Ÿฑ๐ŸŒˆ | Audio Signal Processing Research Student. NTU EEE Class of 2022. Georgia Tech Music Tech Visiting Researcher.
Karn Watcharasupat
Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

Implementation based on Paper - Learning a Probabilistic Latent Space of Object Shapes via 3D Generative-Adversarial Modeling

HamasKhan 3 Jul 8, 2022
Generating images from caption and vice versa via CLIP-Guided Generative Latent Space Search

CLIP-GLaSS Repository for the paper Generating images from caption and vice versa via CLIP-Guided Generative Latent Space Search An in-browser demo is

Federico Galatolo 172 Dec 22, 2022
Framework for joint representation learning, evaluation through multimodal registration and comparison with image translation based approaches

CoMIR: Contrastive Multimodal Image Representation for Registration Framework ?? Registration of images in different modalities with Deep Learning ??

Methods for Image Data Analysis - MIDA 55 Dec 9, 2022
High-Resolution Image Synthesis with Latent Diffusion Models

Latent Diffusion Models Requirements A suitable conda environment named ldm can be created and activated with: conda env create -f environment.yaml co

CompVis Heidelberg 5.6k Jan 4, 2023
Facebook Research 605 Jan 2, 2023
PyTorch implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"

DiscoGAN in PyTorch PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. * All samples in READM

Taehoon Kim 1k Jan 4, 2023
Official implementation of "Learning to Discover Cross-Domain Relations with Generative Adversarial Networks"

DiscoGAN Official PyTorch implementation of Learning to Discover Cross-Domain Relations with Generative Adversarial Networks. Prerequisites Python 2.7

SK T-Brain 754 Dec 29, 2022
PyTorch implementation of the cross-modality generative model that synthesizes dance from music.

Dancing to Music PyTorch implementation of the cross-modality generative model that synthesizes dance from music. Paper Hsin-Ying Lee, Xiaodong Yang,

NVIDIA Research Projects 485 Dec 26, 2022
CVPR 2021 Official Pytorch Code for UC2: Universal Cross-lingual Cross-modal Vision-and-Language Pre-training

UC2 UC2: Universal Cross-lingual Cross-modal Vision-and-Language Pre-training Mingyang Zhou, Luowei Zhou, Shuohang Wang, Yu Cheng, Linjie Li, Zhou Yu,

Mingyang Zhou 28 Dec 30, 2022
Cross Quality LFW: A database for Analyzing Cross-Resolution Image Face Recognition in Unconstrained Environments

Cross-Quality Labeled Faces in the Wild (XQLFW) Here, we release the database, evaluation protocol and code for the following paper: Cross Quality LFW

Martin Knoche 10 Dec 12, 2022
Official Implementation of LARGE: Latent-Based Regression through GAN Semantics

LARGE: Latent-Based Regression through GAN Semantics [Project Website] [Google Colab] [Paper] LARGE: Latent-Based Regression through GAN Semantics Yot

null 83 Dec 6, 2022
Attention-based Transformation from Latent Features to Point Clouds (AAAI 2022)

Attention-based Transformation from Latent Features to Point Clouds This repository contains a PyTorch implementation of the paper: Attention-based Tr

null 12 Nov 11, 2022
Source code for the GPT-2 story generation models in the EMNLP 2020 paper "STORIUM: A Dataset and Evaluation Platform for Human-in-the-Loop Story Generation"

Storium GPT-2 Models This is the official repository for the GPT-2 models described in the EMNLP 2020 paper [STORIUM: A Dataset and Evaluation Platfor

Nader Akoury 27 Dec 20, 2022
An evaluation toolkit for voice conversion models.

Voice-conversion-evaluation An evaluation toolkit for voice conversion models. Sample test pair Generate the metadata for evaluating models. The direc

null 30 Aug 29, 2022
A large-scale video dataset for the training and evaluation of 3D human pose estimation models

ASPset-510 ASPset-510 (Australian Sports Pose Dataset) is a large-scale video dataset for the training and evaluation of 3D human pose estimation mode

Aiden Nibali 36 Oct 30, 2022
A large-scale video dataset for the training and evaluation of 3D human pose estimation models

ASPset-510 (Australian Sports Pose Dataset) is a large-scale video dataset for the training and evaluation of 3D human pose estimation models. It contains 17 different amateur subjects performing 30 sports-related actions each, for a total of 510 action clips.

Aiden Nibali 25 Jun 20, 2021
The Hailo Model Zoo includes pre-trained models and a full building and evaluation environment

Hailo Model Zoo The Hailo Model Zoo provides pre-trained models for high-performance deep learning applications. Using the Hailo Model Zoo you can mea

Hailo 50 Dec 7, 2022