Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch inference #9

Open
Darel13712 opened this issue Nov 29, 2024 · 2 comments
Open

Batch inference #9

Darel13712 opened this issue Nov 29, 2024 · 2 comments

Comments

@Darel13712
Copy link

Hey, mule analyze works fine for a single file, but how do I process the whole dataset without reloading the model for every file?

@MCMcCallum
Copy link
Member

MCMcCallum commented Dec 3, 2024

Typically, to scale this model over large datasets, you may want to use some distributed cloud compute solution such as Google Dataflow. Unfortunately scaling analysis is beyond the scope of this repository, but if you have a dataset that is reasonable to analyze on a single machine, then you could use the classes in this repository directly, rather than relying on the CLI.

Looking at how mule analyze works here:

https://github.com/PandoraMedia/music-audio-representations/blob/main/mule/analysis.py#L61-L68

You can see that the feature class instances persist with each analysis (including the loaded model), and are simply cleared with each new call to analyze. So you could write a simple script that looped over a set of files like so:

from scooch import config
from mule import Analysis

analyze_config = './analyze_config.yaml'
analysis = Analysis(Config(analyze_config))

filenames = get_audio_filenames()

for fname in filenames:
  this_feature = analysis.analyze(fname)
  this_feature.save(get_output_filename(fname))

analysis_config.yaml can be the same configuration you are using with the CLI.

get_audio_filenames() is a function you write to specify which audio file paths you wish to analyze, returning a list of strings specifying each path.

get_output_filename() is a function you write to determine the location to save the feature data to, based on the input filename.

Hope this helps. Reach out if you have any further questions, or issues with the above suggestion.

@Darel13712
Copy link
Author

Yeah, I came up with this solution, but I was wondering if it is possible to load audiofiles in batches into model to speed up the process. Processing 10 audio files at a time for example.

Also, will the file loader understand mp3 or should I convert everything to wav first? Am I correct that converting everything to 16kHz beforehand will also speed up the process?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants