Skip to content

Commit 90df9c4

Browse files
author
Matt Sokoloff
committed
all notebooks colab ready
1 parent 9e9f241 commit 90df9c4

File tree

8 files changed

+2819
-358
lines changed

8 files changed

+2819
-358
lines changed

annotation_type_basics.ipynb

Lines changed: 1393 additions & 0 deletions
Large diffs are not rendered by default.

converters.ipynb

Lines changed: 363 additions & 0 deletions
Large diffs are not rendered by default.

examples/annotation_types/annotation_type_basics.ipynb

Lines changed: 124 additions & 117 deletions
Large diffs are not rendered by default.

examples/annotation_types/converters.ipynb

Lines changed: 103 additions & 58 deletions
Large diffs are not rendered by default.

examples/annotation_types/label_containers.ipynb

Lines changed: 222 additions & 182 deletions
Large diffs are not rendered by default.

label_containers.ipynb

Lines changed: 587 additions & 0 deletions
Large diffs are not rendered by default.

labelbox/data/annotation_types/annotation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any, Dict, List, Union
22

3+
from pydantic.main import BaseModel
4+
35
from .classification import Checklist, Dropdown, Radio, Text
46
from .feature import FeatureSchema
57
from .geometry import Geometry
@@ -9,7 +11,6 @@
911
class BaseAnnotation(FeatureSchema):
1012
""" Base annotation class. Shouldn't be directly instantiated
1113
"""
12-
1314
extra: Dict[str, Any] = {}
1415

1516

labelbox/data/annotation_types/label.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from collections import defaultdict
2+
from labelbox.data.annotation_types import geometry
13
from typing import Any, Dict, List, Tuple, Union, Callable
24

35
from pydantic import BaseModel
@@ -21,6 +23,29 @@ class Label(BaseModel):
2123
VideoClassificationAnnotation, Metric]] = []
2224
extra: Dict[str, Any] = {}
2325

26+
def object_annotations(self) -> List[ObjectAnnotation]:
27+
return [
28+
annot for annot in self.annotations
29+
if isinstance(annot, ObjectAnnotation)
30+
]
31+
32+
def classification_annotations(self) -> List[ClassificationAnnotation]:
33+
return [
34+
annot for annot in self.annotations
35+
if isinstance(annot, ClassificationAnnotation)
36+
]
37+
38+
def frame_annotations(
39+
self
40+
) -> Dict[str, Union[VideoObjectAnnotation, VideoClassificationAnnotation]]:
41+
frame_dict = defaultdict(list)
42+
for annotation in self.annotations:
43+
if isinstance(
44+
annotation,
45+
(VideoObjectAnnotation, VideoClassificationAnnotation)):
46+
frame_dict[annotation.frame].append(annotation)
47+
return frame_dict
48+
2449
def add_url_to_data(self, signer) -> "Label":
2550
"""
2651
Creates signed urls for the data

0 commit comments

Comments
 (0)