Skip to content

fix(common): collect whole labels in FeatureLabel.uniq_labels - #16326

Open
MohammadHijjawi97 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
MohammadHijjawi97:fix-feature-label-uniq-labels
Open

MohammadHijjawi97 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
MohammadHijjawi97:fix-feature-label-uniq-labels

Conversation

@MohammadHijjawi97

Copy link
Copy Markdown

Important

The Update branch button must only be pressed in very rare occassions.
An outdated branch is never blocking the merge of a PR.
Please reach out to the automation team before pressing that button.

What does this PR do ?

Make FeatureLabel.uniq_labels the sorted list of distinct labels instead of a set of the labels' characters, so FeatureToLabelDataset(labels=None) and regression manifests work.

Collection: common (used by ASR FeatureToLabelDataset)

Changelog

  • FeatureLabel now adds each whole label to its unique-label set, and exposes uniq_labels as a sorted list, matching SpeechLabel.uniq_labels. Before, set(label) gave single characters (speech/background became 14 letters). That broke the labels=None fallback of FeatureToLabelDataset with TypeError: 'set' object is not subscriptable, and float labels in regression manifests failed with TypeError: 'float' object is not iterable.
  • Added regression tests to tests/collections/asr/test_label_datasets.py.

Usage

from nemo.collections.asr.data.feature_to_label import FeatureToLabelDataset

ds = FeatureToLabelDataset(manifest_filepath="feat_manifest.json", labels=None)
print(ds.labels)  # ['background', 'speech']

GitHub Actions CI

The Jenkins CI system has been replaced by GitHub Actions self-hosted runners.

Trusted PRs run automatically through copy-pr-bot. For an untrusted PR, a maintainer can trigger CI by commenting
/ok to test <head-sha>; repeat this after a new push if the PR remains untrusted.

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you add or update any necessary documentation?
  • Does the PR affect components that are optional to install? (Ex: Numba, Pynini, Apex etc)
    • Reviewer: Does the PR have correct import guards for all optional libraries?

PR Type:

  • New Feature
  • Bugfix
  • Documentation

If you haven't finished some of the above items you can still open "Draft" PR.

Who can review?

Anyone in the community is free to review the PR once the checks have passed.
Contributor guidelines contains specific people who can review PRs to various areas.

Additional Information

  • Fixes FeatureLabel.uniq_labels collects the characters of each label, breaking FeatureToLabelDataset #16106
  • Checks run (CPU, Python 3.13): pytest --noconftest tests/collections/asr/test_label_datasets.py -k feat_label. The 2 new tests fail on main and pass with the fix, and the existing test_feat_label_dataset still passes. pre-commit run is clean. The other tests in that file need the downloaded test-data archive, so I did not run them locally.
  • No documentation change is needed: this restores the documented "if None, automatically picks from the collection" behaviour.
FeatureLabel accumulated `set(label)` for each manifest entry, so a
classification manifest labelled "speech"/"background" produced a
vocabulary of single characters, and the result was a bare set. The
labels=None fallback of FeatureToLabelDataset then failed with
"TypeError: 'set' object is not subscriptable", and regression
manifests (float labels) failed in ASRFeatureLabel with
"TypeError: 'float' object is not iterable".

Collect whole labels and expose them as a sorted list, matching
SpeechLabel.uniq_labels.

Fixes NVIDIA-NeMo#16106

Signed-off-by: Mohammad Hijjawi <mohammad.hijjawi1997@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Sep 30, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment