merlresearch / sebbs

Prediction of sound event bounding boxes (SEBBs)
GNU Affero General Public License v3.0
19 stars 2 forks source link

sed_scores_from_sebbs: incorrect fill_value when passing a dictionary #2

Closed OptimusPrimus closed 1 month ago

OptimusPrimus commented 2 months ago

Hey,

thanks for making your work available!

There is a minor issue with sed_scores_from_sebbs in sebbs/utils.py that results in an incorrect fill_value when passing a dictionary of SEBBs:

The recursive call here:

    if isinstance(sebbs, dict):
        return {
            key: sed_scores_from_sebbs(
                preds_for_key, sound_classes, audio_duration[key] if audio_duration is not None else None
            )
            for key, preds_for_key in sebbs.items()
        }

results in fill_value being set to -np.inf.

Here is a minimal example:

from sebbs.utils import sed_scores_from_sebbs
csebbs_out = {'asd': [(0, 1, 'Dog', 0.01)]}

result = sed_scores_from_sebbs(csebbs_out, sound_classes=c, fill_value=0.0)
print(result)

A fix could look somewhat like this:

    if isinstance(sebbs, dict):
        return {
            key: sed_scores_from_sebbs(
                preds_for_key, sound_classes, audio_duration[key] if audio_duration is not None else None, fill_value
            )
            for key, preds_for_key in sebbs.items()
        }

Best, Paul

JanekEbb commented 2 months ago

Hi Paul,

thanks for pointing this out. We'll fix this shortly.

Best, Janek

kieranparsons commented 1 month ago

Thank, @OptimusPrimus. The issue is now fixed in https://github.com/merlresearch/sebbs/releases/tag/v1.0.1.