macaodha / batdetect2

Other
53 stars 10 forks source link

Error processing example audio files on Ubuntu 22.04 #3

Closed kdarras closed 1 year ago

kdarras commented 1 year ago

After installing Anaconda 3 and running "python run_batdetect.py example_data/audio/ example_data/anns/ 0.3":

Screenshot from 2023-03-29 14-18-54

Also ran this after manually creating the output folder, same error. No output is created.

macaodha commented 1 year ago

Hi there. Can you share an example audio file so we can debug this.

kdarras commented 1 year ago

Hi there! They are the audio example files that are provided within batdetect2: image

macaodha commented 1 year ago

Hi again. In run_batdetect.py, can you change the following lines:

    for ii, audio_file in enumerate(files):
        print('\n' + str(ii).ljust(6) + os.path.basename(audio_file))
        try:
            results = du.process_file(audio_file, model, params, args)
            if args['save_preds_if_empty'] or (len(results['pred_dict']['annotation']) > 0):
                results_path = audio_file.replace(args['audio_dir'], args['ann_dir'])
                du.save_results_to_file(results, results_path)
        except:
            error_files.append(audio_file)
            print("Error processing file!")

to this:

    for ii, audio_file in enumerate(files):
        print('\n' + str(ii).ljust(6) + os.path.basename(audio_file))
        results = du.process_file(audio_file, model, params, args)
        if args['save_preds_if_empty'] or (len(results['pred_dict']['annotation']) > 0):
            results_path = audio_file.replace(args['audio_dir'], args['ann_dir'])
            du.save_results_to_file(results, results_path)

This should give you a more detailed error that you can share here.

kdarras commented 1 year ago

seems related to librosa:

image

macaodha commented 1 year ago

Yes, looks like it. Can I ask what version of librosa you are using, the requirements file calls for librosa==0.9.2.

kdarras commented 1 year ago

I used librosa 0.10.0. Apparently this was not downgraded during the environment creation.

So I downgraded manually to librosa 0.9.2 using: pip install --force-reinstall -v "librosa==0.9.2"

This solved my problem:

image

Maybe the solution would then be to set up the environment in a way to force librosa 0.9.2 to be installed since the code is not (yet) forward-compatible?

macaodha commented 1 year ago

Great - glad you got it working. We will look into updating the code so that the latest version on librosa is used. I'll keep the issue open for now to remind myself.

kdarras commented 1 year ago

Excellent - looking forward! batdetect2 worked nicely with some sample 10-min Audiomoth recordings, just now.

mbsantiago commented 1 year ago

Hi both! This issue has been addressed in a branch we've been working on. Will merge the changes soon 👍🏽.

macaodha commented 1 year ago

@kdarras cool, will be interested to see how well it works for you.

BTW we have an online demo here that you can also try if interested:
https://huggingface.co/spaces/macaodha/batdetect2

kdarras commented 1 year ago

yes, I tried it, but we have longer audio files :)