Frechet Audio Distance evaluation in PyTorch
Project description
fad_pytorch
Install
pip install fad_pytorch
About
(Intended) Features:
- runs in parallel on multiple GPUs
- supports 48kHz sample rates and stereo when possible
- supports CLAP embeddings, in addition to VGGish and PANN
- favors ops in PyTorch instead of numpy
- allows dataset access via WebDataset (over s3://)
- runs on CPU, CUDA, or MPS
This is designed to be run as 3 command-line scripts in succession. The
latter 2 (fad_embed
and fad_score
) are probably what most people
will want:
fad_gen
: produces directories of real & fake audiofad_embed <real_audio_dir> <fake_audio_dir>
: produces directories of embeddings of real & fake audiofad_score <real_emb_dir> <fake_emb_dir>
: reads the embeddings & generates FAD score, for real (“$r$”) and fake (“$f$”):
$$ FAD = || \mu_r - \mu_f ||^2 + tr\left(\Sigma_r + \Sigma_f - 2 \sqrt{\Sigma_r \Sigma_f}\right)$$
FAQ / Troubleshooting
- “
RuntimeError: CUDA error: invalid device ordinal
”: This happens when you have a “bad node” on an AWS cluster. Haven’t yet figured out what causes it or how to fix it. Workaround: Just add the current node to your SLURM--exclude
list, exit and retry. Note: it may take as many as 5 to 7 retries before you get a “good node”.
Contributing
This repo is still fairly “bare bones” and will benefit from more documentation and features as time goes on. Note that it is written using nbdev, so the things to are:
- fork this repo
- clone your fork to your (local) machine
- Install nbdev:
python3 -m pip install -U nbdev
- Make changes by editing the notebooks in
nbs/
, not the.py
files infad_pytorch/
. - Run
nbdev_export
to export notebook changes to.py
files - For good measure, run
nbdev_install_hooks
andnbdev_clean
- especially if you’ve added any notebooks. - Do a
git status
to see all the.ipynb
and.py
files that need to be added & committed git add
those files and thengit commit
, and thengit push
- Take a look in your GitHub Actions tab, and see if the “test” and “deploy” CI runs finish properly (green light) or fail (red light)
- One you get green lights, send in a Pull Request!
Feel free to ask me for tips with nbdev, it has quite a learning curve. You can also ask on fast.ai forums and/or fast.ai Discord
Related Repos
There are [several] others, but this one is mine. These repos didn’t have all the features I wanted, but I used them for inspiration:
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
File details
Details for the file fad_pytorch-0.0.4.tar.gz
.
File metadata
- Download URL: fad_pytorch-0.0.4.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7a4282b491a5c7700073a4a9f683f22d5f286d2900cb7fe6eaae33dc614dacb |
|
MD5 | 7bbd4ad3249b6c3f688cf370f40af9c4 |
|
BLAKE2b-256 | dddc42afe243bb0d10ce82e911bd5f538845b256edceaf6e032e31f0156b16ce |
File details
Details for the file fad_pytorch-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: fad_pytorch-0.0.4-py3-none-any.whl
- Upload date:
- Size: 31.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e6e3721f8358f7bf91d7eaa7583c03855238f1ab151adb09159abc1cf9b49d6 |
|
MD5 | 23136fae3db800ce3756548ba285af8f |
|
BLAKE2b-256 | 0106be1a267e601e0774146a6d9b4d12b2dfc6a9837b1440166b5c4a5554a058 |