vdschema 0.1.0__tar.gz

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.
@@ -0,0 +1,62 @@
1
+ Metadata-Version: 2.4
2
+ Name: vdschema
3
+ Version: 0.1.0
4
+ Summary: Unified annotation schema and JSONL IO for vision datasets.
5
+ Author-email: xiaokun1 <xiaokun1@sensetime.com>
6
+ Project-URL: Homepage, https://github.com/REPLACE_OWNER/vdschema
7
+ Project-URL: Repository, https://github.com/REPLACE_OWNER/vdschema
8
+ Project-URL: Issues, https://github.com/REPLACE_OWNER/vdschema/issues
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: numpy>=1.26
12
+ Requires-Dist: pycocotools>=2.0.7
13
+
14
+ # vdschema
15
+
16
+ Unified annotation schema and JSONL IO for vision datasets.
17
+
18
+ `vdschema` can be used by annotation pipelines to write JSONL annotation files
19
+ and by training pipelines to read those files back into typed Python objects.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ uv sync
25
+ ```
26
+
27
+ ## Basic Usage
28
+
29
+ ```python
30
+ from vdschema import AnnotationReader, AnnotationWriter, DetectionAnnotation
31
+
32
+ writer = AnnotationWriter("output/detection/annotation_meta.jsonl", DetectionAnnotation)
33
+ writer.append(
34
+ filename="images/sample.jpg",
35
+ width=640,
36
+ height=480,
37
+ instances=[
38
+ {"id": 0, "category_id": 1, "bbox": [10, 20, 100, 200]},
39
+ ],
40
+ )
41
+ writer.save()
42
+
43
+ annotations = AnnotationReader(
44
+ "output/detection/annotation_meta.jsonl",
45
+ DetectionAnnotation,
46
+ ).load()
47
+ ```
48
+
49
+ ## Development
50
+
51
+ ```bash
52
+ uv sync --group dev
53
+ uv run python test_annotation_format.py
54
+ uv run ruff check .
55
+ uv build
56
+ ```
57
+
58
+ ## Publishing
59
+
60
+ This repository includes a GitHub Actions workflow for publishing to PyPI with
61
+ trusted publishing. Configure the PyPI project and GitHub environment before
62
+ creating a release.
@@ -0,0 +1,49 @@
1
+ # vdschema
2
+
3
+ Unified annotation schema and JSONL IO for vision datasets.
4
+
5
+ `vdschema` can be used by annotation pipelines to write JSONL annotation files
6
+ and by training pipelines to read those files back into typed Python objects.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ uv sync
12
+ ```
13
+
14
+ ## Basic Usage
15
+
16
+ ```python
17
+ from vdschema import AnnotationReader, AnnotationWriter, DetectionAnnotation
18
+
19
+ writer = AnnotationWriter("output/detection/annotation_meta.jsonl", DetectionAnnotation)
20
+ writer.append(
21
+ filename="images/sample.jpg",
22
+ width=640,
23
+ height=480,
24
+ instances=[
25
+ {"id": 0, "category_id": 1, "bbox": [10, 20, 100, 200]},
26
+ ],
27
+ )
28
+ writer.save()
29
+
30
+ annotations = AnnotationReader(
31
+ "output/detection/annotation_meta.jsonl",
32
+ DetectionAnnotation,
33
+ ).load()
34
+ ```
35
+
36
+ ## Development
37
+
38
+ ```bash
39
+ uv sync --group dev
40
+ uv run python test_annotation_format.py
41
+ uv run ruff check .
42
+ uv build
43
+ ```
44
+
45
+ ## Publishing
46
+
47
+ This repository includes a GitHub Actions workflow for publishing to PyPI with
48
+ trusted publishing. Configure the PyPI project and GitHub environment before
49
+ creating a release.
@@ -0,0 +1,43 @@
1
+ [project]
2
+ name = "vdschema"
3
+ version = "0.1.0"
4
+ description = "Unified annotation schema and JSONL IO for vision datasets."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "xiaokun1", email = "xiaokun1@sensetime.com" }
8
+ ]
9
+ requires-python = ">=3.12"
10
+ dependencies = [
11
+ "numpy>=1.26",
12
+ "pycocotools>=2.0.7",
13
+ ]
14
+
15
+ [project.urls]
16
+ Homepage = "https://github.com/REPLACE_OWNER/vdschema"
17
+ Repository = "https://github.com/REPLACE_OWNER/vdschema"
18
+ Issues = "https://github.com/REPLACE_OWNER/vdschema/issues"
19
+
20
+ [build-system]
21
+ requires = ["setuptools>=61"]
22
+ build-backend = "setuptools.build_meta"
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "pytest>=8.0",
27
+ "ruff>=0.8.0",
28
+ "build>=1.2.0",
29
+ "twine>=5.0.0",
30
+ ]
31
+
32
+ [tool.setuptools]
33
+ packages = ["vdschema"]
34
+
35
+ [tool.setuptools.package-data]
36
+ vdschema = ["*.json"]
37
+
38
+ [tool.pytest.ini_options]
39
+ testpaths = ["."]
40
+ python_files = ["test_*.py"]
41
+
42
+ [tool.ruff]
43
+ line-length = 88
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
+ }