FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Added "allow_new_labels" flag for class_labels tensor by nvoxland-al · Pull Request #2830 · activeloopai/deeplake · GitHub

Added "allow_new_labels" flag for class_labels tensor - #2830

Draft
nvoxland-al wants to merge 1 commit into
mainfrom
allow_new_labels_flag
Draft

Added "allow_new_labels" flag for class_labels tensor#2830
nvoxland-al wants to merge 1 commit into
mainfrom
allow_new_labels_flag

Conversation

Copy link
Copy Markdown
Contributor

🚀 🚀 Pull Request

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

By default, tensors with htype="class_label" will accept any new values added to them. This PR adds a new allow_new_labels=False setting in the tensor "info" which changes that behavior to instead throw an exception if an unknown label is added.

The available labels are set in the info["class_names"] setting, either when the tensor is originally created:

        ds.create_tensor(
            "labels",
            htype="class_label",
            class_names=["cat", "dog", "horse"],
            allow_new_labels=False,
        )

or set/updated later:

ds.labels.info.update(allow_new_labels=False)
ds.labels.info.update(class_names=["cat", "dog", "horse")

Things to be aware of

If you update the class_names to be a different order or skipping existing labels, the label_id->text mapping will be off and reading from the tensor will give you incorrect results.

Copy link
Copy Markdown

nvoxland-al marked this pull request as draft July 12, 2024 14:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL