|
| 1 | +import abc |
1 | 2 | from typing import Any, Dict, List, Union |
2 | 3 |
|
3 | 4 | from .classification import Checklist, Dropdown, Radio, Text |
4 | 5 | from .feature import FeatureSchema |
5 | | -from .geometry import Geometry |
| 6 | +from .geometry import Geometry, Rectangle, Point |
6 | 7 | from .ner import TextEntity |
7 | 8 |
|
8 | 9 |
|
9 | | -class BaseAnnotation(FeatureSchema): |
| 10 | +class BaseAnnotation(FeatureSchema, abc.ABC): |
10 | 11 | """ Base annotation class. Shouldn't be directly instantiated |
11 | 12 | """ |
12 | 13 | extra: Dict[str, Any] = {} |
13 | 14 |
|
14 | 15 |
|
15 | 16 | class ClassificationAnnotation(BaseAnnotation): |
16 | | - """Class representing classification annotations (annotations that don't have a location) """ |
| 17 | + """Classification annotations (non localized) |
| 18 | +
|
| 19 | + >>> ClassificationAnnotation( |
| 20 | + >>> value=Text(answer="my caption message"), |
| 21 | + >>> feature_schema_id="my-feature-schema-id" |
| 22 | + >>> ) |
| 23 | +
|
| 24 | + Args: |
| 25 | + name (Optional[str]) |
| 26 | + feature_schema_id (Optional[Cuid]) |
| 27 | + value (Union[Text, Checklist, Radio, Dropdown]) |
| 28 | + extra (Dict[str, Any]) |
| 29 | + """ |
17 | 30 |
|
18 | 31 | value: Union[Text, Checklist, Radio, Dropdown] |
19 | 32 |
|
20 | 33 |
|
21 | 34 | class ObjectAnnotation(BaseAnnotation): |
22 | | - """Class representing objects annotations (non classifications or annotations that have a location) |
| 35 | + """Generic localized annotation (non classifications) |
| 36 | +
|
| 37 | + >>> ObjectAnnotation( |
| 38 | + >>> value=Rectangle( |
| 39 | + >>> start=Point(x=0, y=0), |
| 40 | + >>> end=Point(x=1, y=1) |
| 41 | + >>> ), |
| 42 | + >>> feature_schema_id="my-feature-schema-id" |
| 43 | + >>> ) |
| 44 | +
|
| 45 | + Args: |
| 46 | + name (Optional[str]) |
| 47 | + feature_schema_id (Optional[Cuid]) |
| 48 | + value (Union[TextEntity, Geometry]): Localization of the annotation |
| 49 | + classifications (Optional[List[ClassificationAnnotation]]): Optional sub classification of the annotation |
| 50 | + extra (Dict[str, Any]) |
23 | 51 | """ |
24 | 52 | value: Union[TextEntity, Geometry] |
25 | 53 | classifications: List[ClassificationAnnotation] = [] |
26 | 54 |
|
27 | 55 |
|
28 | 56 | class VideoObjectAnnotation(ObjectAnnotation): |
29 | | - """ |
30 | | - Class for video objects annotations |
| 57 | + """Video object annotation |
| 58 | +
|
| 59 | + >>> VideoObjectAnnotation( |
| 60 | + >>> keyframe=True, |
| 61 | + >>> frame=10, |
| 62 | + >>> value=Rectangle( |
| 63 | + >>> start=Point(x=0, y=0), |
| 64 | + >>> end=Point(x=1, y=1) |
| 65 | + >>> ), |
| 66 | + >>> feature_schema_id="my-feature-schema-id" |
| 67 | + >>>) |
31 | 68 |
|
32 | 69 | 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 |
| 70 | + name (Optional[str]) |
| 71 | + feature_schema_id (Optional[Cuid]) |
| 72 | + value (Geometry) |
| 73 | + frame (Int): The frame index that this annotation corresponds to |
| 74 | + keyframe (bool): Whether or not this annotation was a human generated or interpolated annotation |
| 75 | + classifications (List[ClassificationAnnotation]) = [] |
| 76 | + extra (Dict[str, Any]) |
35 | 77 | """ |
36 | 78 | frame: int |
37 | 79 | keyframe: bool |
38 | 80 |
|
39 | 81 |
|
40 | 82 | class VideoClassificationAnnotation(ClassificationAnnotation): |
41 | | - """ |
42 | | - Class for video classification annotations |
| 83 | + """Video classification |
43 | 84 |
|
44 | 85 | Args: |
45 | | - frame: The frame index that this annotation corresponds to |
| 86 | + name (Optional[str]) |
| 87 | + feature_schema_id (Optional[Cuid]) |
| 88 | + value (Union[Text, Checklist, Radio, Dropdown]) |
| 89 | + frame (int): The frame index that this annotation corresponds to |
| 90 | + extra (Dict[str, Any]) |
46 | 91 | """ |
47 | 92 | frame: int |
0 commit comments