Skip to content

Commit 79afd99

Browse files
authored
Merge pull request #201 from Labelbox/ms/core-annotation-types
annotation types
2 parents 4344d8e + c9e5877 commit 79afd99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2369
-22
lines changed

.github/workflows/python-package.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ jobs:
4747
uses: AlexanderMelde/yapf-action@master
4848
with:
4949
args: --verbose --recursive --parallel --style "google"
50-
50+
- name: dependencies
51+
run: |
52+
sudo apt-get -y update
53+
sudo apt install -y libsm6 \
54+
libxext6 \
55+
ffmpeg \
56+
libfontconfig1 \
57+
libxrender1 \
58+
libgl1-mesa-glx
5159
- name: install labelbox package
5260
run: |
53-
python setup.py install
61+
python -m pip install --upgrade pip
62+
python -m pip install .
5463
- name: mypy
5564
run: |
56-
python -m pip install --upgrade pip
5765
pip install mypy==0.782
5866
mypy -p labelbox --pretty --show-error-codes
5967
- name: Install package and test dependencies

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
FROM python:3.7
22

33
RUN pip install pytest pytest-cases
4+
RUN apt-get -y update
5+
RUN apt install -y libsm6 \
6+
libxext6 \
7+
ffmpeg \
8+
libfontconfig1 \
9+
libxrender1 \
10+
libgl1-mesa-glx
411

512
WORKDIR /usr/src/labelbox
613
COPY requirements.txt /usr/src/labelbox
714
RUN pip install -r requirements.txt
815
COPY . /usr/src/labelbox
916

10-
1117
RUN python setup.py install

labelbox/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
from labelbox.schema.asset_attachment import AssetAttachment
1717
from labelbox.schema.webhook import Webhook
1818
from labelbox.schema.prediction import Prediction, PredictionModel
19-
from labelbox.schema.ontology import Ontology
19+
from labelbox.schema.ontology import Ontology, OntologyBuilder, Classification, Option, Tool
2020
from labelbox.schema.role import Role, ProjectRole
2121
from labelbox.schema.invite import Invite, InviteLimit

labelbox/data/__init__.py

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from .geometry import Line
2+
from .geometry import Point
3+
from .geometry import Mask
4+
from .geometry import Polygon
5+
from .geometry import Rectangle
6+
from .geometry import Geometry
7+
8+
from .annotation import ClassificationAnnotation
9+
from .annotation import VideoClassificationAnnotation
10+
from .annotation import ObjectAnnotation
11+
from .annotation import VideoObjectAnnotation
12+
13+
from .ner import TextEntity
14+
15+
from .classification import Checklist
16+
from .classification import ClassificationAnswer
17+
from .classification import Dropdown
18+
from .classification import Radio
19+
from .classification import Text
20+
21+
from .data import RasterData
22+
from .data import TextData
23+
from .data import VideoData
24+
25+
from .label import Label
26+
27+
from .collection import LabelList
28+
from .collection import LabelGenerator
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import Any, Dict, List, Union
2+
3+
from .classification import Checklist, Dropdown, Radio, Text
4+
from .feature import FeatureSchema
5+
from .geometry import Geometry
6+
from .ner import TextEntity
7+
8+
9+
class BaseAnnotation(FeatureSchema):
10+
""" Base annotation class. Shouldn't be directly instantiated
11+
"""
12+
13+
extra: Dict[str, Any] = {}
14+
15+
16+
class ClassificationAnnotation(BaseAnnotation):
17+
"""Class representing classification annotations (annotations that don't have a location) """
18+
value: Union[Text, Checklist, Radio, Dropdown]
19+
20+
21+
class ObjectAnnotation(BaseAnnotation):
22+
"""Class representing objects annotations (non classifications or annotations that have a location)
23+
"""
24+
value: Union[TextEntity, Geometry]
25+
classifications: List[ClassificationAnnotation] = []
26+
27+
28+
class VideoObjectAnnotation(ObjectAnnotation):
29+
"""
30+
Class for video objects annotations
31+
32+
Args:
33+
frame: The frame index that this annotation corresponds to
34+
keyframe: Whether or not this annotation was a human generated or interpolated annotation
35+
"""
36+
frame: int
37+
keyframe: bool
38+
39+
40+
class VideoClassificationAnnotation(ClassificationAnnotation):
41+
"""
42+
Class for video classification annotations
43+
44+
Args:
45+
frame: The frame index that this annotation corresponds to
46+
"""
47+
frame: int
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .classification import (Checklist, ClassificationAnswer, Dropdown, Radio,
2+
Text)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import Any, Dict, List
2+
3+
from pydantic.main import BaseModel
4+
5+
from ..feature import FeatureSchema
6+
7+
8+
class ClassificationAnswer(FeatureSchema):
9+
"""
10+
- Represents a classification option.
11+
- Because it inherits from FeatureSchema
12+
the option can be represented with either the name or schema_id
13+
"""
14+
extra: Dict[str, Any] = {}
15+
16+
17+
class Radio(BaseModel):
18+
""" A classification with only one selected option allowed """
19+
answer: ClassificationAnswer
20+
21+
22+
class Checklist(BaseModel):
23+
""" A classification with many selected options allowed """
24+
answer: List[ClassificationAnswer]
25+
26+
27+
class Text(BaseModel):
28+
""" Free form text """
29+
answer: str
30+
31+
32+
class Dropdown(BaseModel):
33+
"""
34+
- A classification with many selected options allowed .
35+
- This is not currently compatible with MAL.
36+
"""
37+
answer: List[ClassificationAnswer]

0 commit comments

Comments
 (0)