Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata improvements #234

Merged
merged 9 commits into from
Jan 24, 2025
Merged

Metadata improvements #234

merged 9 commits into from
Jan 24, 2025

Conversation

kozlov721
Copy link
Collaborator

@kozlov721 kozlov721 commented Jan 24, 2025

  • Added a Category type that can be used with the task metadata to signify the value is categorical as opposed to a general string
  • Added new fields to the LuxonisDataset.metadata
    • "categorical_encodings" containing numerical encodings for categorical metadata tasks
    • "metadata_types" containing a mapping from metadata tasks to their python types
    • Added corresponding getters to LuxonisDataset
      • get_categorical_encodings
      • get_metadata_types
  • New parameter keep_categorical_as_strings in LuxonisLoader, default is False
    • If False, the loader output will contain the category ids instead of the string values
  • Fixed a few small issues with metadata labels

This change allows for better flexibility in luxonis-train for models requiring metadata labels.

Example:

from luxonis_ml.data import Category

def generator():
    yield {
        "task": "vehicles",
        ...,
        "metadata": {
            "color": Category("red")  # one of "red", "green", "blue"
            "license_plate": "xyz",
            "distance": 12.4,
            "id": 4,
        }
    }

dataset = LuxonisDataset(...)
dataset.add(generator)
assert dataset.get_categorical_encodings() == {
    "vehicles/metadata/color": {"red": 0, "green": 1, "blue": 2}}
}
assert dataset.get_metadata_types() == {
    "vehicles/metadata/color": "Category",
    "vehicles/metadata/license_plate": "str",
    "vehicles/metadata/distance": "float",
    "vehicles/metadata/id": "int",
}

@kozlov721 kozlov721 requested a review from a team as a code owner January 24, 2025 07:37
@kozlov721 kozlov721 requested review from klemen1999, tersekmatija and conorsim and removed request for a team January 24, 2025 07:37
@kozlov721 kozlov721 changed the title Metadata encodings Categorical metadata Jan 24, 2025
@github-actions github-actions bot added enhancement New feature or request data Changes affecting luxonis_ml.data subpackage labels Jan 24, 2025
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 93.93939% with 4 lines in your changes missing coverage. Please review.

Project coverage is 95.77%. Comparing base (a770f26) to head (a49b687).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
luxonis_ml/data/datasets/luxonis_dataset.py 91.83% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #234      +/-   ##
==========================================
- Coverage   95.79%   95.77%   -0.03%     
==========================================
  Files          90       90              
  Lines        4785     4828      +43     
==========================================
+ Hits         4584     4624      +40     
- Misses        201      204       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kozlov721 kozlov721 changed the title Categorical metadata Metadata improvements Jan 24, 2025
@kozlov721 kozlov721 merged commit 2858ae8 into main Jan 24, 2025
10 of 12 checks passed
@kozlov721 kozlov721 deleted the feature/metadata-ids branch January 24, 2025 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data Changes affecting luxonis_ml.data subpackage enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants