Skip to content

Commit 3e98d9d

Browse files
authored
Merge pull request #210 from Labelbox/ms/mea-annotation
mea-annotation
2 parents 54c89a4 + 90fbd4e commit 3e98d9d

File tree

18 files changed

+344
-468
lines changed

18 files changed

+344
-468
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
- project.create_prediction_model()
99
- project.create_label()
1010

11-
1211
# Version 2.7b1+mea (2021-06-27)
1312
## Fix
1413
* No longer convert `ModelRun.created_by_id` to cuid on construction of a `ModelRun`.
@@ -19,7 +18,6 @@
1918
* Update `AnnotationGroup` to expect labelId to be a cuid instead of uuid.
2019
* Update `datarow_miou` to support masks with multiple classes in them.
2120

22-
2321
# Version 2.7.0 (2021-06-27)
2422
## Added
2523
* Added `dataset.export_data_rows()` which returns all `DataRows` for a `Dataset`.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test-staging: build
66
docker run -it -v ${PWD}:/usr/src -w /usr/src \
77
-e LABELBOX_TEST_ENVIRON="staging" \
88
-e LABELBOX_TEST_API_KEY_STAGING=${LABELBOX_TEST_API_KEY_STAGING} \
9-
local/labelbox-python:test pytest $(PATH_TO_TEST) -svv
9+
local/labelbox-python:test pytest $(PATH_TO_TEST) -svvx
1010

1111
test-prod: build
1212
docker run -it -v ${PWD}:/usr/src -w /usr/src \

labelbox/data/annotation_types/data/raster.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import numpy as np
55
import requests
6+
from google.api_core import retry
67
from typing_extensions import Literal
78
from pydantic import root_validator
89
from PIL import Image
@@ -84,6 +85,7 @@ def data(self) -> np.ndarray:
8485
def set_fetch_fn(self, fn):
8586
object.__setattr__(self, 'fetch_remote', lambda: fn(self))
8687

88+
@retry.Retry(deadline=15.)
8789
def fetch_remote(self) -> bytes:
8890
"""
8991
Method for accessing url.
@@ -95,6 +97,7 @@ def fetch_remote(self) -> bytes:
9597
response.raise_for_status()
9698
return response.content
9799

100+
@retry.Retry(deadline=15.)
98101
def create_url(self, signer: Callable[[bytes], str]) -> str:
99102
"""
100103
Utility for creating a url from any of the other image representations.

labelbox/data/annotation_types/data/text.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Callable, Optional
22

33
import requests
4+
from google.api_core import retry
45
from pydantic import root_validator
56

67
from .base_data import BaseData
@@ -39,6 +40,7 @@ def data(self) -> str:
3940
def set_fetch_fn(self, fn):
4041
object.__setattr__(self, 'fetch_remote', lambda: fn(self))
4142

43+
@retry.Retry(deadline=15.)
4244
def fetch_remote(self) -> str:
4345
"""
4446
Method for accessing url.
@@ -50,6 +52,7 @@ def fetch_remote(self) -> str:
5052
response.raise_for_status()
5153
return response.text
5254

55+
@retry.Retry(deadline=15.)
5356
def create_url(self, signer: Callable[[bytes], str]) -> None:
5457
"""
5558
Utility for creating a url from any of the other text references.

labelbox/data/annotation_types/data/video.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import cv2
99
import numpy as np
10+
from google.api_core import retry
1011
from pydantic import root_validator
1112

1213
from .base_data import BaseData
@@ -89,6 +90,7 @@ def __getitem__(self, idx: int) -> np.ndarray:
8990
def set_fetch_fn(self, fn):
9091
object.__setattr__(self, 'fetch_remote', lambda: fn(self))
9192

93+
@retry.Retry(deadline=15.)
9294
def fetch_remote(self, local_path) -> None:
9395
"""
9496
Method for downloading data from self.url
@@ -101,6 +103,7 @@ def fetch_remote(self, local_path) -> None:
101103
"""
102104
urllib.request.urlretrieve(self.url, local_path)
103105

106+
@retry.Retry(deadline=15.)
104107
def create_url(self, signer: Callable[[bytes], str]) -> None:
105108
"""
106109
Utility for creating a url from any of the other video references.

labelbox/data/annotation_types/feature.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class FeatureSchema(BaseModel):
1919

2020
@root_validator
2121
def must_set_one(cls, values):
22+
2223
if values['schema_id'] is None and values['name'] is None:
2324
raise ValueError(
2425
"Must set either schema_id or name for all feature schemas")

labelbox/data/annotation_types/label.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .metrics import Metric
1313
from .annotation import (ClassificationAnnotation, ObjectAnnotation,
1414
VideoClassificationAnnotation, VideoObjectAnnotation)
15+
from labelbox.data.annotation_types import annotation
1516

1617

1718
class Label(BaseModel):
@@ -22,15 +23,14 @@ class Label(BaseModel):
2223
extra: Dict[str, Any] = {}
2324

2425
def object_annotations(self) -> List[ObjectAnnotation]:
25-
return [
26-
annot for annot in self.annotations
27-
if isinstance(annot, ObjectAnnotation)
28-
]
26+
return self.get_annotations_by_type(ObjectAnnotation)
2927

3028
def classification_annotations(self) -> List[ClassificationAnnotation]:
29+
return self.get_annotations_by_type(ClassificationAnnotation)
30+
31+
def get_annotations_by_type(self, annotation_type):
3132
return [
32-
annot for annot in self.annotations
33-
if isinstance(annot, ClassificationAnnotation)
33+
annot for annot in self.annotations if isinstance(annotation_type)
3434
]
3535

3636
def frame_annotations(

0 commit comments

Comments
 (0)