Skip to main content

Compute frecet wavelet distances

Project description

FWD LOGO

Fréchet Wavelet Distance: A Domain-Agnostic Metric for Image Generation

Lokesh Veeramacheneni1, Moritz Wolter1, Hilde Kuehne2, and Juergen Gall1,3

1. University of Bonn
2. University of Tübingen, MIT-IBM Watson AI Lab
3. Lamarr Institute for Machine Learning and Artificial Intelligence

Documentation Status License CodeStyle Workflow Paper Downloads Project Page

Keywords: Frechet Distance, Wavelet Packet Transform, FID, Diffusion, GAN, ImageNet, FD-DINOv2,

Abstract: Modern metrics for generative learning like Fréchet Inception Distance (FID) and DINOv2-Fréchet Distance (FD-DINOv2) demonstrate impressive performance. However, they suffer from various shortcomings, like a bias towards specific generators and datasets. To address this problem, we propose the Fréchet Wavelet Distance (FWD) as a domain-agnostic metric based on the Wavelet Packet Transform (\(W_p\)). FWD provides a sight across a broad spectrum of frequencies in images with a high resolution, preserving both spatial and textural aspects. Specifically, we use (\(W_p\)) to project generated and real images to the packet coefficient space. We then compute the Fréchet distance with the resultant coefficients to evaluate the quality of a generator. This metric is general-purpose and dataset-domain agnostic, as it does not rely on any pre-trained network while being more interpretable due to its ability to compute Fréchet distance per packet, enhancing transparency. We conclude with an extensive evaluation of a wide variety of generators across various datasets that the proposed FWD can generalize and improve robustness to domain shifts and various corruptions compared to other metrics.

Alternative text

Installation

Install via pip

pip install pytorchfwd

Usage

python -m pytorchfwd <path to dataset> <path to generated images>

Here are the other arguments and defaults used.

python -m pytorchfwd --help

usage: pytorchfwd.py [-h] [--batch-size BATCH_SIZE] [--num-processes NUM_PROCESSES] [--save-packets] [--wavelet WAVELET] [--max_level MAX_LEVEL] [--log_scale] path path

positional arguments:
  path                  Path to the generated images or path to .npz statistics file.

options:
  -h, --help            show this help message and exit
  --batch-size          Batch size for wavelet packet transform. (default: 128)
  --num-processes       Number of multiprocess. (default: None)
  --save-packets        Save the packets as npz file. (default: False)
  --wavelet             Choice of wavelet. (default: Haar)
  --max_level           wavelet decomposition level (default: 4)
  --log_scale           Use log scaling for wavelets. (default: False)
  --resize              Additional resizing. (deafult: None)

We conduct all the experiments with `Haar` wavelet with transformation/decomposition level of `4` for `256x256` image. The choice of max_level is dependent on the image resolution to maintain sufficient spial and frequency information. For 256 image-level 4, 128 image-level 3 and so on. In future, we plan to release the jax-version of this code.

Citation

If you use this work, please cite using following bibtex entry

@inproceedings{veeramacheneni25fwd,
author={Lokesh Veeramacheneni and Moritz Wolter and Hilde Kuehne and Juergen Gall},
title={Fréchet Wavelet Distance: A Domain-Agnostic Metric for Image Generation},
year={2025},
cdate={1735689600000},
url={https://openreview.net/forum?id=QinkNNKZ3b},
booktitle={ICLR},
crossref={conf/iclr/2025}}

Acknowledgments

The code is built with inspiration from Pytorch-FID. We use PyTorch Wavelet Toolbox for Wavelet Packet Transform implementation. We recommend to have a look at these repositories.

Testing

The tests folder contains tests to conduct independent verification of FWD. Github workflow executes all these tests. To run tests on your local system install nox, as well as this package via pip install ., and run

nox -s test

Funding

This research was supported by the Federal Ministry of Education and Research (BMBF) under grant no.01IS22094A WEST-AI and 6DHBK1022 BNTrAInee, the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) GA 1927/9-1 (KI-FOR 5351) and the ERC Consolidator Grant FORHUE (101044724). Prof. Kuehne is supported by BMBF project STCL - 01IS22067. The authors gratefully acknowledge the Gauss Centre for Supercomputing e.V.(www.gauss-centre.eu) for funding this project by providing computing time through the John von Neumann Institute for Computing (NIC) on the GCS Supercomputer JUWELS at Jülich Supercomputing Centre (JSC). The authors heartfully thank all the volunteers who participated in the user study. The sole responsibility for the content of this publication lies with the authors.

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

pytorchfwd-1.0.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytorchfwd-1.0.1-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pytorchfwd-1.0.1.tar.gz.

File metadata

  • Download URL: pytorchfwd-1.0.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pytorchfwd-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5ed7a56da4adf7783c5c9c3b309f4c6ba6c299e1ea8d78add1a75bc3638d6a54
MD5 495a4112b4141d104c63927956ef8d57
BLAKE2b-256 70ca5071a3a3a93de34180b27b40a58cc32ab69fb1e54070b4526707fd7f0c41

See more details on using hashes here.

File details

Details for the file pytorchfwd-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pytorchfwd-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for pytorchfwd-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 122401b917195ed4ef08ebae0bfd42312022e292cbe80a77adbd6b6bb0fde6bd
MD5 6e9875818e03dc3e39d0aaa2ab06eafc
BLAKE2b-256 9a7037c2177cd07574d7420dc95286ab2398625320074359048d3a3ba2c67b8b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page