Bin
2025-12-16 7423b0c6e1959f30a7e8e453e953310f32ce13c6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
result_example = [
    {
        'original_width': 1920,
        'original_height': 1080,
        'image_rotation': 0,
        'from_name': 'bboxes',
        'to_name': 'image',
        'type': 'rectanglelabels',
        'value': {
            'x': 20,
            'y': 30,
            'width': 50,
            'height': 60,
            'rotation': 0,
            'values': {'rectanglelabels': ['Person']},
        },
    }
]
 
task_response_example = {
    'id': 1,
    'data': {'image': 'https://example.com/image.jpg', 'text': 'Hello, AI!'},
    'project': 1,
    'created_at': '2024-06-18T23:45:46.048490Z',
    'updated_at': '2024-06-18T23:45:46.048538Z',
    'is_labeled': False,
    'overlap': 1,
    'inner_id': 1,
    'total_annotations': 0,
    'cancelled_annotations': 0,
    'total_predictions': 0,
    'comment_count': 0,
    'unresolved_comment_count': 0,
    'last_comment_updated_at': '2024-01-15T09:30:00Z',
    'updated_by': [{'user_id': 1}],
    'file_upload': '42d46c4c-my-pic.jpeg',
    'comment_authors': [1],
}
 
dm_task_response_example = {
    'id': 13,
    'predictions': [],
    'annotations': [],
    'drafts': [],
    'annotators': [],
    'inner_id': 2,
    'cancelled_annotations': 0,
    'total_annotations': 0,
    'total_predictions': 0,
    'completed_at': None,
    'annotations_results': '',
    'predictions_results': '',
    'predictions_score': None,
    'file_upload': '6b25fc23-some_3.mp4',
    'storage_filename': None,
    'annotations_ids': '',
    'predictions_model_versions': '',
    'avg_lead_time': None,
    'draft_exists': False,
    'updated_by': [],
    'data': {'image': '/data/upload/1/6b25fc23-some_3.mp4'},
    'meta': {},
    'created_at': '2024-06-18T23:45:46.048490Z',
    'updated_at': '2024-06-18T23:45:46.048538Z',
    'is_labeled': False,
    'overlap': 1,
    'comment_count': 0,
    'unresolved_comment_count': 0,
    'last_comment_updated_at': None,
    'project': 1,
    'comment_authors': [],
}
 
annotation_response_example = {
    'id': 1,
    'result': result_example,
    'task': 1,
    'project': 1,
    'completed_by': 1,
    'updated_by': 1,
    'was_cancelled': False,
    'ground_truth': False,
    'lead_time': 10,
}
 
prediction_response_example = {'id': 1, 'task': 1, 'result': result_example, 'score': 0.95, 'model_version': 'yolo-v8'}
 
# Task request schema following OpenAPI 3.0 specification
task_request_schema = {
    'type': 'object',
    'properties': {
        'data': {
            'title': 'Task data',
            'description': 'Task data dictionary with arbitrary keys and values',
            'type': 'object',
            'example': {'image': 'https://example.com/image.jpg', 'text': 'Hello, world!'},
        },
        'project': {'type': 'integer', 'description': 'Project ID'},
    },
    'example': {
        'data': {'image': 'https://example.com/image.jpg', 'text': 'Hello, world!'},
        'project': 1,
    },
}
 
# Annotation request schema following OpenAPI 3.0 specification
annotation_request_schema = {
    'type': 'object',
    'properties': {
        'result': {
            'type': 'array',
            'items': {'type': 'object'},
            'description': 'Labeling result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/task_format)',
            'example': result_example,
        },
        'task': {'type': 'integer', 'description': 'Corresponding task for this annotation'},
        'project': {'type': 'integer', 'description': 'Project ID for this annotation'},
        'completed_by': {'type': 'integer', 'description': 'User ID of the person who created this annotation'},
        'updated_by': {'type': 'integer', 'description': 'Last user who updated this annotation'},
        'was_cancelled': {'type': 'boolean', 'description': 'User skipped the task'},
        'ground_truth': {'type': 'boolean', 'description': 'This annotation is a Ground Truth'},
        'lead_time': {
            'type': 'number',
            'description': 'How much time it took to annotate the task (in seconds)',
            'example': 100.5,
        },
    },
    'required': [],
    'example': {
        'result': result_example,
        'was_cancelled': False,
        'ground_truth': True,
    },
}
 
# Prediction request schema following OpenAPI 3.0 specification
prediction_request_schema = {
    'type': 'object',
    'properties': {
        'task': {'type': 'integer', 'description': 'Task ID for which the prediction is created'},
        'result': {
            'type': 'array',
            'items': {'type': 'object'},
            'description': 'Prediction result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/predictions)',
            'example': result_example,
        },
        'score': {
            'type': 'number',
            'description': 'Prediction score. Can be used in Data Manager to sort task by model confidence. Task with the lowest score will be shown first.',
            'example': 0.95,
        },
        'model_version': {
            'type': 'string',
            'description': 'Model version - tag for predictions that can be used to filter tasks in Data Manager, as well as select specific model version for showing preannotations in the labeling interface',
            'example': 'yolo-v8',
        },
    },
    'example': {'result': result_example, 'score': 0.95, 'model_version': 'yolo-v8'},
}