DM Schema V1/V2 Converter
A bidirectional converter between DM Schema V1 and V2 formats.
Overview
The DM Schema Converter transforms annotation data between V1 and V2 formats:
- V1 → V2: Convert legacy V1 data to modern V2 structure
- V2 → V1: Reverse convert V2 data to V1 format (legacy system compatibility)
Key Features
Separated Output Structure
V1→V2 conversion returns two separate parts:
annotation_data: V2 common annotation structure (id, classification, attrs, data)annotation_meta: Preserved V1 top-level structure (meta information)
This separation enables:
- Use
annotation_dataalone for V2 common format - Combine with
annotation_metafor complete V1 restoration
Supported Tools
| Tool | V1 → V2 | V2 → V1 | Media Type | Notes |
|---|---|---|---|---|
bounding_box | ✅ | ✅ | image | rotation preserved |
polygon | ✅ | ✅ | image | point IDs auto-generated |
polyline | ✅ | ✅ | image | point IDs auto-generated |
keypoint | ✅ | ✅ | image | single point coordinate |
3d_bounding_box | ✅ | ✅ | pcd | PSR coordinate system |
segmentation | ✅ | ✅ | image/video | image: pixel_indices, video: section |
3d_segmentation | ✅ | ✅ | pcd | point indices |
named_entity | ✅ | ✅ | text | NER tagging |
classification | ✅ | ✅ | image | no data (empty object) |
relation | ✅ | ✅ | image/text | annotation relationships |
prompt | ✅ | ✅ | prompt | prompt input |
answer | ✅ | ✅ | prompt | answer output |
Quick Start
Installation
pip install synapse-sdk
V1 → V2 Conversion
from synapse_sdk.utils.converters.dm import convert_v1_to_v2
# V1 data
v1_data = {
"annotations": {
"image_1": [
{
"id": "ann_1",
"tool": "bounding_box",
"classification": {"class": "person"}
}
]
},
"annotationsData": {
"image_1": [
{
"id": "ann_1",
"coordinate": {"x": 100, "y": 200, "width": 150, "height": 100}
}
]
}
}
# Convert to V2 (separated result)
result = convert_v1_to_v2(v1_data)
annotation_data = result["annotation_data"] # V2 common structure
annotation_meta = result["annotation_meta"] # V1 top-level structure
V2 → V1 Conversion
from synapse_sdk.utils.converters.dm import convert_v2_to_v1
# Complete conversion (annotation_data + annotation_meta)
v1_restored = convert_v2_to_v1(result)
# Convert with annotation_data only (uses defaults)
v1_basic = convert_v2_to_v1({"annotation_data": annotation_data})
Detailed Guides
Image Tools
- Bounding Box Conversion - Bounding box annotation conversion
- Polygon Conversion - Polygon annotation conversion
- Polyline Conversion - Polyline annotation conversion
- Keypoint Conversion - Keypoint annotation conversion
- Segmentation Conversion (Image) - Image segmentation conversion
- Classification Conversion - Classification annotation conversion
- Relation Conversion - Annotation relationship conversion
Video Tools
- Segmentation Conversion (Video) - Video segmentation conversion
PCD (Point Cloud) Tools
- 3D Bounding Box Conversion - 3D bounding box conversion
- 3D Segmentation Conversion - 3D segmentation conversion
Text Tools
- Named Entity Recognition Conversion - NER annotation conversion
Prompt Tools
- Prompt Conversion - Prompt annotation conversion
- Answer Conversion - Answer annotation conversion
Developer Documentation
- Developer Guide - How to add new tools
API Reference
convert_v1_to_v2(v1_data)
Converts V1 data to V2 format.
Parameters:
v1_data: DM Schema V1 format data
Returns:
V2ConversionResult: Dictionary containingannotation_dataandannotation_meta
convert_v2_to_v1(v2_data, annotation_meta=None)
Converts V2 data to V1 format.
Parameters:
v2_data: DM Schema V2 format data or V2ConversionResultannotation_meta: Optional V1 top-level structure passed separately
Returns:
- DM Schema V1 format data