vdschema 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vdschema/__init__.py ADDED
@@ -0,0 +1,56 @@
1
+ """Unified annotation schema and JSONL IO."""
2
+
3
+ from .annotation_io import AnnotationReader, AnnotationWriter
4
+ from .annotation_format import (
5
+ ANNOTATION_CLASSES,
6
+ ActionAnnotation,
7
+ ActionEvent,
8
+ BaseAnnotation,
9
+ Bbox,
10
+ ClassificationAnnotation,
11
+ ClassificationHead,
12
+ ContentImage,
13
+ ContentText,
14
+ ConversationAnnotation,
15
+ ConversationRole,
16
+ ConversationTurn,
17
+ DataFormatError,
18
+ DetectionAnnotation,
19
+ Instance,
20
+ Keypoint,
21
+ KeypointAnnotation,
22
+ Relationship,
23
+ RelationshipAnnotation,
24
+ SegmentationAnnotation,
25
+ SegmentationRLE,
26
+ TrackItem,
27
+ VlmAnnotation,
28
+ )
29
+
30
+ __all__ = [
31
+ "ANNOTATION_CLASSES",
32
+ "ActionAnnotation",
33
+ "ActionEvent",
34
+ "AnnotationReader",
35
+ "AnnotationWriter",
36
+ "BaseAnnotation",
37
+ "Bbox",
38
+ "ClassificationAnnotation",
39
+ "ClassificationHead",
40
+ "ContentImage",
41
+ "ContentText",
42
+ "ConversationAnnotation",
43
+ "ConversationRole",
44
+ "ConversationTurn",
45
+ "DataFormatError",
46
+ "DetectionAnnotation",
47
+ "Instance",
48
+ "Keypoint",
49
+ "KeypointAnnotation",
50
+ "Relationship",
51
+ "RelationshipAnnotation",
52
+ "SegmentationAnnotation",
53
+ "SegmentationRLE",
54
+ "TrackItem",
55
+ "VlmAnnotation",
56
+ ]
@@ -0,0 +1,266 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://example.org/schemas/label-dict.schema.json",
4
+ "title": "标注标签词典",
5
+ "description": "数据集级检测类别、图像分类、关系类型、动作标签等 ID 与名称对照。",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "annotation_schema_ref": {
10
+ "type": "string",
11
+ "description": "对应标注 schema 的 $id 或版本摘要。",
12
+ "examples": [
13
+ "https://example.org/schemas/image_schema.json",
14
+ "https://example.org/schemas/video_schema.json"
15
+ ]
16
+ },
17
+ "detection": {
18
+ "type": "array",
19
+ "description": "检测/实例类别词表;与标注 **`instances[].category_id`** 对应。",
20
+ "minItems": 1,
21
+ "items": {
22
+ "$ref": "#/$defs/category_entry"
23
+ }
24
+ },
25
+ "classification": {
26
+ "type": "array",
27
+ "description": "图像级多分类词表;与标注顶层 **`categories[]`**(按 **`category_type`**)对应。",
28
+ "minItems": 1,
29
+ "items": {
30
+ "$ref": "#/$defs/classification_entry"
31
+ }
32
+ },
33
+ "relationship": {
34
+ "type": "array",
35
+ "description": "关系类型;标注 **`relationships[].relation_type`** 等与词表对齐(字段含义见 **`relationship_entry`**)。",
36
+ "minItems": 1,
37
+ "items": {
38
+ "$ref": "#/$defs/relationship_entry"
39
+ }
40
+ },
41
+ "action": {
42
+ "type": "array",
43
+ "description": "动作/事件类标签词表(若标注侧含对应 ID 字段则与之对齐)。",
44
+ "minItems": 1,
45
+ "items": {
46
+ "$ref": "#/$defs/action_entry"
47
+ }
48
+ },
49
+ "dataset_metadata": {
50
+ "$ref": "#/$defs/dataset_metadata",
51
+ "description": "数据来源与许可等(可选)。"
52
+ }
53
+ },
54
+ "allOf": [
55
+ {
56
+ "description": "下列词表至少须出现其一,且出现时数组须非空:**`detection`** / **`classification`** / **`relationship`** / **`action`**。",
57
+ "anyOf": [
58
+ {
59
+ "required": [
60
+ "detection"
61
+ ]
62
+ },
63
+ {
64
+ "required": [
65
+ "classification"
66
+ ]
67
+ },
68
+ {
69
+ "required": [
70
+ "relationship"
71
+ ]
72
+ },
73
+ {
74
+ "required": [
75
+ "action"
76
+ ]
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "examples": [
82
+ {
83
+ "annotation_schema_ref": "https://example.org/schemas/perception-annotation.schema.json",
84
+ "detection": [
85
+ {
86
+ "category_id": 1,
87
+ "category_name": "person"
88
+ },
89
+ {
90
+ "category_id": 2,
91
+ "category_name": "car"
92
+ }
93
+ ],
94
+ "classification": [
95
+ {
96
+ "category_type": "scene",
97
+ "values": [
98
+ {
99
+ "category_id": 10,
100
+ "category_name": "intersection"
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "category_type": "weather",
106
+ "values": [
107
+ {
108
+ "category_id": 3,
109
+ "category_name": "sunny"
110
+ },
111
+ {
112
+ "category_id": 4,
113
+ "category_name": "cloudy"
114
+ }
115
+ ]
116
+ }
117
+ ],
118
+ "relationship": [
119
+ {
120
+ "relationship_id": 0,
121
+ "relationship_name": "左边"
122
+ },
123
+ {
124
+ "relationship_id": 1,
125
+ "relationship_name": "右边"
126
+ }
127
+ ],
128
+ "action": [
129
+ {
130
+ "action_id": 3,
131
+ "action_name": "walking"
132
+ },
133
+ {
134
+ "action_id": 4,
135
+ "action_name": "talking"
136
+ }
137
+ ],
138
+ "dataset_metadata": {
139
+ "source": "internal_lab",
140
+ "language": "zh-CN",
141
+ "license": "CC-BY-4.0",
142
+ "difficulty": "medium",
143
+ "quality_score": 0.92
144
+ }
145
+ }
146
+ ],
147
+ "$defs": {
148
+ "category_entry": {
149
+ "type": "object",
150
+ "additionalProperties": false,
151
+ "properties": {
152
+ "category_id": {
153
+ "type": "integer",
154
+ "description": "类别 ID(≥0)。",
155
+ "minimum": 0
156
+ },
157
+ "category_name": {
158
+ "type": "string",
159
+ "description": "类别名称。",
160
+ "minLength": 1
161
+ }
162
+ },
163
+ "required": [
164
+ "category_id",
165
+ "category_name"
166
+ ]
167
+ },
168
+ "classification_entry": {
169
+ "type": "object",
170
+ "additionalProperties": false,
171
+ "properties": {
172
+ "category_type": {
173
+ "type": "string",
174
+ "description": "分类头键,须与标注 **`categories[].category_type`** 一致。",
175
+ "minLength": 1,
176
+ "examples": [
177
+ "scene",
178
+ "weather"
179
+ ]
180
+ },
181
+ "values": {
182
+ "type": "array",
183
+ "description": "该头下允许的取值(结构与 **`category_entry`** 相同)。",
184
+ "minItems": 1,
185
+ "items": {
186
+ "$ref": "#/$defs/category_entry"
187
+ }
188
+ }
189
+ },
190
+ "required": [
191
+ "category_type",
192
+ "values"
193
+ ]
194
+ },
195
+ "relationship_entry": {
196
+ "type": "object",
197
+ "additionalProperties": false,
198
+ "properties": {
199
+ "relationship_id": {
200
+ "type": "integer",
201
+ "description": "关系 ID(≥0)。",
202
+ "minimum": 0
203
+ },
204
+ "relationship_name": {
205
+ "type": "string",
206
+ "description": "关系名称。",
207
+ "minLength": 1,
208
+ "examples": [
209
+ "靠近",
210
+ "左边"
211
+ ]
212
+ }
213
+ },
214
+ "required": [
215
+ "relationship_id",
216
+ "relationship_name"
217
+ ]
218
+ },
219
+ "action_entry": {
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "properties": {
223
+ "action_id": {
224
+ "type": "integer",
225
+ "description": "动作标签 ID(≥0)。",
226
+ "minimum": 0
227
+ },
228
+ "action_name": {
229
+ "type": "string",
230
+ "description": "动作名称。",
231
+ "minLength": 1
232
+ }
233
+ },
234
+ "required": [
235
+ "action_id",
236
+ "action_name"
237
+ ]
238
+ },
239
+ "dataset_metadata": {
240
+ "type": "object",
241
+ "additionalProperties": false,
242
+ "properties": {
243
+ "source": {
244
+ "type": "string",
245
+ "description": "数据来源。"
246
+ },
247
+ "language": {
248
+ "type": "string",
249
+ "description": "主语言,如 zh-CN。"
250
+ },
251
+ "license": {
252
+ "type": "string",
253
+ "description": "许可证。"
254
+ },
255
+ "difficulty": {
256
+ "type": "string",
257
+ "description": "难度(自定义枚举)。"
258
+ },
259
+ "quality_score": {
260
+ "type": "number",
261
+ "description": "质量分(可选)。"
262
+ }
263
+ }
264
+ }
265
+ }
266
+ }