Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 73
PTDT-3807: Add temporal audio annotation support#2013
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
e4fd630dbcc7bfdbb592fff298d416896fd7a666ccac58ad067dd14aa1600e5b4d2f42fadb14e1e12596c2a7b4c26a35fdb16f2ea943cb73a8385130ca9cd678615376c3c50a68773cf58b30f70a63def538ba669675c73327800b1174ad82361ca359f0cd8b186359e63b3066b54e26ccad765735bb09db3fb5eb0d5ee4126633866e4c44471c618478fb2382e90e1fb8df4af2025861e424effb209f015bb17bc28a7cad2dc65876bdf3558aaf629afd82dad2223cf49a1d8File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -13,6 +13,10 @@ | ||
| from .metrics import ScalarMetric, ConfusionMatrixMetric | ||
| from .video import VideoClassificationAnnotation | ||
| from .video import VideoObjectAnnotation, VideoMaskAnnotation | ||
| from .temporal import ( | ||
| TemporalClassificationText, | ||
| TemporalClassificationQuestion, | ||
| ) | ||
| from .mmc import MessageEvaluationTaskAnnotation | ||
| from pydantic import BaseModel, field_validator | ||
| @@ -44,6 +48,8 @@ class Label(BaseModel): | ||
| ClassificationAnnotation, | ||
| ObjectAnnotation, | ||
| VideoMaskAnnotation, | ||
| TemporalClassificationText, | ||
| TemporalClassificationQuestion, | ||
| ScalarMetric, | ||
| ConfusionMatrixMetric, | ||
| RelationshipAnnotation, | ||
| @@ -63,8 +69,22 @@ def validate_data(cls, data): | ||
| def object_annotations(self) -> List[ObjectAnnotation]: | ||
| return self._get_annotations_by_type(ObjectAnnotation) | ||
| def classification_annotations(self) -> List[ClassificationAnnotation]: | ||
| return self._get_annotations_by_type(ClassificationAnnotation) | ||
| def classification_annotations( | ||
| self, | ||
| ) -> List[ | ||
| Union[ | ||
| ClassificationAnnotation, | ||
| TemporalClassificationText, | ||
| TemporalClassificationQuestion, | ||
| ] | ||
| ]: | ||
| return self._get_annotations_by_type( | ||
| ( | ||
| ClassificationAnnotation, | ||
| TemporalClassificationText, | ||
| TemporalClassificationQuestion, | ||
| ) | ||
| ) | ||
| def _get_annotations_by_type(self, annotation_type): | ||
| return [ | ||
| @@ -75,15 +95,58 @@ def _get_annotations_by_type(self, annotation_type): | ||
| def frame_annotations( | ||
| self, | ||
| ) -> Dict[str, Union[VideoObjectAnnotation, VideoClassificationAnnotation]]: | ||
| ) -> Dict[ | ||
| Union[int, None], | ||
| List[ | ||
| Union[ | ||
| VideoObjectAnnotation, | ||
| VideoClassificationAnnotation, | ||
| TemporalClassificationText, | ||
| TemporalClassificationQuestion, | ||
| ] | ||
| ], | ||
| ]: | ||
rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| """Get temporal annotations organized by frame | ||
| Returns: | ||
| Dict[int, List]: Dictionary mapping frame (milliseconds) to list of temporal annotations | ||
| Example: | ||
| >>> label.frame_annotations() | ||
| {2500: [VideoClassificationAnnotation(...), TemporalClassificationText(...)]} | ||
| Note: | ||
| For TemporalClassificationText/Question, returns dictionary mapping to start of first frame range. | ||
| These annotations may have multiple discontinuous frame ranges. | ||
| """ | ||
| frame_dict = defaultdict(list) | ||
| for annotation in self.annotations: | ||
| if isinstance( | ||
| annotation, | ||
| (VideoObjectAnnotation, VideoClassificationAnnotation), | ||
| ): | ||
| frame_dict[annotation.frame].append(annotation) | ||
| return frame_dict | ||
| elif isinstance( | ||
| annotation, | ||
| (TemporalClassificationText, TemporalClassificationQuestion), | ||
| ): | ||
| # For temporal annotations with multiple values/answers, use first frame | ||
| if ( | ||
| isinstance(annotation, TemporalClassificationText) | ||
| and annotation.value | ||
| ): | ||
| frame_dict[annotation.value[0][0]].append( | ||
| annotation | ||
| ) # value[0][0] is start_frame | ||
| elif ( | ||
| isinstance(annotation, TemporalClassificationQuestion) | ||
| and annotation.value | ||
| ): | ||
| if annotation.value[0].frames: | ||
| frame_dict[annotation.value[0].frames[0][0]].append( | ||
| annotation | ||
| ) # frames[0][0] is start_frame | ||
| return dict(frame_dict) | ||
rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. rishisurana-labelbox marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def add_url_to_masks(self, signer) -> "Label": | ||
| """ | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.