Skip to content

Regression: Custom classifier export fails when labels contain multiple underscores #941

Description

@fegue

Describe the bug

The model training/export process fails when custom classifier labels contain multiple underscores.

Our custom label system appends vocalization types to a base label using underscores. However, BirdNET appears to split the label on _ and expects exactly two parts. When a label contains more than one underscore, the export fails with:

ValueError: Columns must be same length as key

The error appears to occur in birdnet_analyzer/analyze/core.py, for example at:

df[["Scientific name", "Common name"]] = df["species_name"].str.split(
    "_", expand=True
)

This split creates more than two columns when the label contains multiple underscores.

Example labels that trigger the issue:

Pipile pipile_Trinidad Piping-Guan_v=full song 1
Pipile pipile_Trinidad Piping-Guan_v=instrumental

These labels contain more than one underscore, so splitting on _ returns more than two parts and causes the assignment to fail.

Expected behavior

Custom classifier labels with multiple underscores should not cause the export or training process to fail.

BirdNET should either:

  • split only on the first underscore, or
  • support labels containing multiple underscores, or
  • validate the label format earlier and provide a clear error message explaining the allowed format.

Screenshots

Desktop (please complete the following information):

  • OS: Ubuntu 20.04

Additional context

This breaks for custom labels that use additional underscores to encode vocalization types or other metadata.
If multiple underscores are not acceptable please clarify custom label format.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions