GithubHelp home page GithubHelp logo

dr-costas / coala Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xavierfav/coala

0.0 0.0 0.0 74.3 MB

COALA: Co-Aligned Autoencoders for Learning Semantically Enriched Audio Representations

License: MIT License

Python 97.50% Shell 2.50%

coala's Introduction

COALA: Co-Aligned Autoencoders for Learning Semantically Enriched Audio Representations

This is the repository for the method presented in the paper: "COALA: Co-Aligned Autoencoders for Learning Semantically Enriched Audio Representations" by X. Favory, K. Drossos, T. Virtanen, and X. Serra. (arXiv)

Install python dependencies

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Reproduce the results of the paper

Training the embedding models

If you want to train the embeddings from scratch, you will need to download the dataset from this Zenodo page and place the hdf5 files in the hdf5_ds/ directory. Then you can launch the training of an embedding model by running for instance:

python train_dual_ae.py 'configs/dual_ae_c.json'

The config file may be edited for instance to select which device to use for training ('cuda' or 'cpu').

Downtream classification tasks

If you want to re-compute the classification accuracies on the downstream tasks, you will need to:

  1. download the three datasets:

  2. place their content into the directory data/ as following:

    data
    └─── UrbanSound8K
    │     └─── audio
    │     └─── metadata
    └─── GTZAN
    │     └─── genres
    │     └─── test_filtered.txt
    │     └─── train_filtered.txt
    └─── nsynth
         └─── nsynth-train
               └─── audio_selected
         └───  nsynth-test
    

    keeping existing sub-directories as they are for each dataset. However, for NSynth, you will have to manually create the audio_selected/ folder and put there the files that are listed in the values of the dictionary stored in json/nsynth_selected_sounds_per_class.json.

  3. compute the embeddings with the pre-trained (or re-trained) embedding models runing the encode.py script. This will store the embedding files into the data/embedding/ directory.

Use the pre-trained embedding models

You can use the embedding models on your own data. You will need to create your own script, but the idea is simple. Here is a simple example to extract embedding chunks given an audio file:

from encode import return_loaded_model, extract_audio_embedding_chunks
from models_t1000 import AudioEncoder

model = return_loaded_model(AudioEncoder, 'saved_models/dual_ae_c/audio_encoder_epoch_200.pt')
embedding, _ = extract_audio_embedding_chunks(model, '<path/to/audio/file>')

   __         __            
 /"  "\     /"  "\                            _    
(  (\  )___(  /)  )                          | |    
 \               /             ___ ___   __ _| | __ _ 
 /               \            / __/ _ \ / _` | |/ _` |
/    () ___ ()    \          | (_| (_) | (_| | | (_| |
|      (   )      |           \___\___/ \__,_|_|\__,_|
 \      \_/      /           
   \...__!__.../              

coala's People

Contributors

xavierfav avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.