**************************************************************************
Fréchet Wavelet Distance: A Domain-Agnostic Metric for Image Generation
**************************************************************************
`Lokesh Veeramacheneni <https://lokiv.dev>`__\ :sup:`1`, `Moritz
Wolter <https://www.wolter.tech/>`__\ :sup:`1`, `Hilde
Kuehne <https://hildekuehne.github.io/>`__\ :sup:`1,2`, and `Juergen
Gall <https://pages.iai.uni-bonn.de/gall_juergen/>`__\ :sup:`1`
| 1. *University of Bonn*,
| 2. *University of Tübingen, MIT-IBM Watson AI Lab*.
|
[`Archive <https://arxiv.org/pdf/2312.15289>`__] [`Project
Page <https://lokiv.dev/frechet_wavelet_distance/>`__]
|Workflow| |License| |CodeStyle|
**Keywords:** Frechet Distance, Wavelet Packet Transform, Frechet
Inception Distance, Diffusion, GAN, ImageNet, Image generation metrics.
**Abstract:** Modern metrics for generative learning like Fréchet
Inception Distance (FID) 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 Wavelet
Packet Transform (:math:`W_p`). FWD provides a sight across a
broad spectrum of frequencies in images with a high resolution, along
with preserving both spatial and textural aspects. Specifically, we use
:math:`W_p` to project generated and dataset images to packet
coefficient space. Further, we compute 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 because
of frequency band transparency. We conclude with an extensive evaluation
of a wide variety of generators across various datasets that the
proposed FWD is able to generalize and improve robustness to domain
shift and various corruptions compared to other metrics.
.. image:: https://github.com/NeuralHPC/PyTorch-FWD/blob/master/images/fwd_computation.png
:width: 100%
:alt: Alternative text
Installation
============
Install via pip
.. code:: bash
pip install pytorchfwd
Usage
=====
.. code:: bash
python -m pytorchfwd <path to dataset> <path to generated images>
Here are the other arguments and defaults used.
.. code-block::
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: sym5)
--max_level wavelet decomposition level (default: 4)
--log_scale Use log scaling for wavelets. (default: False)
We conduct all the experiments with `Haar` wavelet with transformation/decomposition level of `4` for `256x256` image.
In future, we plan to release the jax-version of this code.
Citation
========
If you use this work, please cite using following bibtex entry
.. code-block::
@misc{veeramacheneni2024fwd,
title={Fr\'echet Wavelet Distance: A Domain-Agnostic Metric for Image Generation},
author={Lokesh Veeramacheneni and Moritz Wolter and Hildegard Kuehne and Juergen Gall},
year={2024},
eprint={2312.15289},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2312.15289},
}
Acknowledgments
===============
The code is built with inspiration from
`Pytorch-FID <https://github.com/mseitzer/pytorch-fid>`__. We use
`PyTorch Wavelet
Toolbox <https://github.com/v0lta/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
.. code-block:: sh
nox -s test
.. |Workflow| image:: https://github.com/Uni-Bonn-Attention-Research/frechet_wavelet_distance/actions/workflows/tests.yml/badge.svg
:target: https://github.com/NeuralHPC/PyTorch-FWD/actions/workflows/tests.yml
.. |License| image:: https://img.shields.io/badge/License-Apache_2.0-blue.svg
:target: https://opensource.org/licenses/Apache-2.0
.. |CodeStyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
Raw data
{
"_id": null,
"home_page": "https://github.com/NeuralHPC/PyTorch-FWD",
"name": "pytorchfwd",
"maintainer": "Lokesh Veeramacheneni",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "lokeshveeramacheneni27@gmail.com",
"keywords": "Wavelets, Wavelet Transform, Fast Wavelet Transform, PyTorch, Generative Learning",
"author": "Lokesh Veeramacheneni",
"author_email": "lokeshveeramacheneni27@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/34/23/5d768059e0b8f99e35c5726feb4d3a47123c9e5cea74b6da1fdc3ee3af21/pytorchfwd-0.0.4.tar.gz",
"platform": null,
"description": "\n**************************************************************************\nFr\u00e9chet Wavelet Distance: A Domain-Agnostic Metric for Image Generation\n**************************************************************************\n\n`Lokesh Veeramacheneni <https://lokiv.dev>`__\\ :sup:`1`, `Moritz\nWolter <https://www.wolter.tech/>`__\\ :sup:`1`, `Hilde\nKuehne <https://hildekuehne.github.io/>`__\\ :sup:`1,2`, and `Juergen\nGall <https://pages.iai.uni-bonn.de/gall_juergen/>`__\\ :sup:`1`\n\n| 1. *University of Bonn*, \n| 2. *University of T\u00fcbingen, MIT-IBM Watson AI Lab*.\n|\n\n[`Archive <https://arxiv.org/pdf/2312.15289>`__] [`Project\nPage <https://lokiv.dev/frechet_wavelet_distance/>`__]\n\n|Workflow| |License| |CodeStyle|\n\n**Keywords:** Frechet Distance, Wavelet Packet Transform, Frechet\nInception Distance, Diffusion, GAN, ImageNet, Image generation metrics.\n\n**Abstract:** Modern metrics for generative learning like Fr\u00e9chet\nInception Distance (FID) demonstrate impressive performance. However,\nthey suffer from various shortcomings, like a bias towards specific\ngenerators and datasets. To address this problem, we propose the Fr\u00e9chet\nWavelet Distance (FWD) as a domain-agnostic metric based on Wavelet\nPacket Transform (:math:`W_p`). FWD provides a sight across a\nbroad spectrum of frequencies in images with a high resolution, along\nwith preserving both spatial and textural aspects. Specifically, we use\n:math:`W_p` to project generated and dataset images to packet\ncoefficient space. Further, we compute Fr\u00e9chet distance with the\nresultant coefficients to evaluate the quality of a generator. This\nmetric is general-purpose and dataset-domain agnostic, as it does not\nrely on any pre-trained network while being more interpretable because\nof frequency band transparency. We conclude with an extensive evaluation\nof a wide variety of generators across various datasets that the\nproposed FWD is able to generalize and improve robustness to domain\nshift and various corruptions compared to other metrics.\n\n.. image:: https://github.com/NeuralHPC/PyTorch-FWD/blob/master/images/fwd_computation.png\n :width: 100%\n :alt: Alternative text\n\nInstallation\n============\n\nInstall via pip \n\n.. code:: bash\n\n pip install pytorchfwd\n\n\nUsage\n=====\n\n.. code:: bash\n\n python -m pytorchfwd <path to dataset> <path to generated images>\n\nHere are the other arguments and defaults used.\n\n.. code-block::\n\n python -m pytorchfwd --help\n \n usage: pytorchfwd.py [-h] [--batch-size BATCH_SIZE] [--num-processes NUM_PROCESSES] [--save-packets] [--wavelet WAVELET] [--max_level MAX_LEVEL] [--log_scale] path path\n \n positional arguments:\n path Path to the generated images or path to .npz statistics file.\n \n options:\n -h, --help show this help message and exit\n --batch-size Batch size for wavelet packet transform. (default: 128)\n --num-processes Number of multiprocess. (default: None)\n --save-packets Save the packets as npz file. (default: False)\n --wavelet Choice of wavelet. (default: sym5)\n --max_level wavelet decomposition level (default: 4)\n --log_scale Use log scaling for wavelets. (default: False)\n\nWe conduct all the experiments with `Haar` wavelet with transformation/decomposition level of `4` for `256x256` image.\nIn future, we plan to release the jax-version of this code.\n\nCitation\n========\nIf you use this work, please cite using following bibtex entry\n\n.. code-block::\n\n @misc{veeramacheneni2024fwd,\n title={Fr\\'echet Wavelet Distance: A Domain-Agnostic Metric for Image Generation}, \n author={Lokesh Veeramacheneni and Moritz Wolter and Hildegard Kuehne and Juergen Gall},\n year={2024},\n eprint={2312.15289},\n archivePrefix={arXiv},\n primaryClass={cs.CV},\n url={https://arxiv.org/abs/2312.15289},\n }\n\nAcknowledgments\n===============\n\nThe code is built with inspiration from\n`Pytorch-FID <https://github.com/mseitzer/pytorch-fid>`__. We use\n`PyTorch Wavelet\nToolbox <https://github.com/v0lta/PyTorch-Wavelet-Toolbox>`__ for\nWavelet Packet Transform implementation. We recommend to have a look at\nthese repositories.\n\nTesting\n=======\nThe `tests` folder contains tests to conduct independent verification of FWD. Github workflow executes all these tests.\nTo run tests on your local system install `nox`, as well as this package via `pip install .`, and run\n\n.. code-block:: sh\n\n nox -s test\n\n\n.. |Workflow| image:: https://github.com/Uni-Bonn-Attention-Research/frechet_wavelet_distance/actions/workflows/tests.yml/badge.svg\n :target: https://github.com/NeuralHPC/PyTorch-FWD/actions/workflows/tests.yml\n.. |License| image:: https://img.shields.io/badge/License-Apache_2.0-blue.svg\n :target: https://opensource.org/licenses/Apache-2.0\n.. |CodeStyle| image:: https://img.shields.io/badge/code%20style-black-000000.svg\n :target: https://github.com/psf/black\n",
"bugtrack_url": null,
"license": "Apache-2.0 license",
"summary": "Compute frecet wavelet distances",
"version": "0.0.4",
"project_urls": {
"Bug Tracker": "https://github.com/NeuralHPC/PyTorch-FWD/issues",
"Download": "https://github.com/NeuralHPC/PyTorch-FWD/releases",
"Homepage": "https://github.com/NeuralHPC/PyTorch-FWD",
"Source Code": "https://github.com/NeuralHPC/PyTorch-FWD"
},
"split_keywords": [
"wavelets",
" wavelet transform",
" fast wavelet transform",
" pytorch",
" generative learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cdcef5834e6027d61bdb5d37f3379a1a2b6c16102e6047a09d1c5cd00c5f6d6b",
"md5": "05f7e2aa975b2d910a7c47013a709ad3",
"sha256": "99e3f49d0e6bfb660f101bf467bdad20a116a2a6e817524f6af5f318e9c3b982"
},
"downloads": -1,
"filename": "pytorchfwd-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "05f7e2aa975b2d910a7c47013a709ad3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 13991,
"upload_time": "2024-08-09T11:14:09",
"upload_time_iso_8601": "2024-08-09T11:14:09.901513Z",
"url": "https://files.pythonhosted.org/packages/cd/ce/f5834e6027d61bdb5d37f3379a1a2b6c16102e6047a09d1c5cd00c5f6d6b/pytorchfwd-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "34235d768059e0b8f99e35c5726feb4d3a47123c9e5cea74b6da1fdc3ee3af21",
"md5": "0847a1908478ff9d6ef702bd1497e88f",
"sha256": "7ec6ec396a55bfc463fa6916baeee0e130d73897f328d453e664e53b3702abe8"
},
"downloads": -1,
"filename": "pytorchfwd-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "0847a1908478ff9d6ef702bd1497e88f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 19055,
"upload_time": "2024-08-09T11:14:12",
"upload_time_iso_8601": "2024-08-09T11:14:12.907377Z",
"url": "https://files.pythonhosted.org/packages/34/23/5d768059e0b8f99e35c5726feb4d3a47123c9e5cea74b6da1fdc3ee3af21/pytorchfwd-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-09 11:14:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "NeuralHPC",
"github_project": "PyTorch-FWD",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pytorchfwd"
}