Create a job
post
https://api.playment.io
/v1/projects/:project_id/jobs
A JOB

Payload

1
{
2
"reference_id":"001",
3
"data":{
4
"video_data": {
5
"frames": [
6
{
7
"frame_id": "frame001",
8
"src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+1"
9
},
10
{
11
"frame_id": "frame002",
12
"src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+2"
13
},
14
{
15
"frame_id": "frame003",
16
"src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+3"
17
},
18
{
19
"frame_id": "frame004",
20
"src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+4"
21
},
22
{
23
"frame_id": "frame005",
24
"src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+5"
25
}
26
]
27
}
28
},
29
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
30
}
Copied!

Code Example

Python
1
import requests
2
import json
3
4
"""
5
Details for creating JOBS,
6
project_id ->> ID of project in which the job will be created
7
x_api_key ->> API key for authentication
8
workflow_id ->> The workflow in which the job will be created
9
batch_id ->> The batch in which job will be created
10
"""
11
12
#method that can be used to call the job creation api
13
def create_job(project_id, data, x_api_key):
14
base_url = "https://api.playment.io/v0/projects/{}/jobs".format(project_id)
15
headers = {'x-api-key': x_api_key}
16
response = requests.post(base_url, headers=headers, json=data)
17
18
print(response.json())
19
if response.status_code >= 500:
20
raise Exception(response.text)
21
if 400 <= response.status_code < 500:
22
raise Exception(response.text)
23
return response.json()
24
25
if __name__ == "__main__":
26
#list of frames in a single job
27
28
frames = ["https://example.com/image_url_1","https://example.com/image_url_2","https://example.com/image_url_3"]
29
30
#reference_id should be unique for each job
31
reference_id= "job1"
32
33
project_id = ''
34
x_api_key = ''
35
workflow_id = ''
36
batch_id = ''
37
38
39
video_data = {'frames' : []}
40
41
i=0
42
for frame_url in frames:
43
i=i+1
44
frame_id = "frame"+str(i)
45
frame_obj = {'src':frame_url,'frame_id':frame_id}
46
video_data['frames'].append(frame_obj)
47
job_data = {
48
'reference_id':reference_id,
49
'work_flow_id':workflow_id,
50
'data':{'video_data':video_data},
51
'batch_id' : batch_id
52
}
53
54
55
56
response = create_job(project_id=project_id, data=job_data, x_api_key= x_api_key)
57
print(response)
58
Copied!

Creating jobs with pre-labeled data

If you have data which has been labeled previously by an ML model or by human labelers, you can create jobs with such labels already created. To do this, you need to send the annotation data in the data.maker_response key in the payload. The annotation data needs to be in Playment's annotation format.
Here's an example
1
{
2
"reference_id":"001",
3
"data":{
4
"video_data": {
5
"frames": [...]
6
},
7
"maker_response" : {
8
"video2d": {
9
"data": {
10
"annotations": []
11
}
12
}
13
}
14
},
15
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
16
}
Copied!
The data.maker_response.video_2d.data.annotations list contains objects, where each object is a tracker. A tracker tracks an object across frames. The frames key in the tracker object maps each annotation object in the tracker to the frame_id it belongs to.
1
{
2
"_id": "",
3
"type": "rectangle", // rectangle/polygon/line/cuboid/landmark
4
"label": "Cat",
5
"frames" : {
6
"frame001" : {<annotation_object>}
7
}
8
}
Copied!
You can check the structure for various annotation_object below:
Rectangles
Polygon
Line
Cuboid
Landmark
1
{
2
"_id": "0e6d895e-2484-439a-b62b-d8a0afb3d190",
3
"label": "".
4
"attributes": {
5
"pose": {
6
"value": "standing"
7
},
8
"breed": {
9
"value": "Persian"
10
}
11
}
12
"coordinates": [
13
{"x": 0.00398, "y": 0.00558},
14
{"x": 0.05404, "y": 0.00558},
15
{"x": 0.05404, "y": 0.09096},
16
{"x": 0.00398, "y": 0.09096}
17
]
18
}
Copied!
1
{
2
"_id": "8f8897ad-e07b-4e55-9dbe-61f6b9df85c5",
3
"label": "face_mask",
4
"attributes": {
5
"covers_nose": {
6
"value": "Yes"
7
},
8
}
9
"points": {
10
"p1": {"x": 0.286774, "y": 0.892502},
11
"p2": {"x": 0.385849, "y": 0.576888},
12
"p3": {"x": 0.426721, "y": 0.469081},
13
"p4": {"x": 0.288623, "y": 0.253878},
14
"p5": {"x": 0.148623, "y": 0.353878}
15
},
16
"edges": {
17
"e1": ["p1", "p2"],
18
"e2": ["p2", "p3"],
19
"e3": ["p3", "p4"],
20
"e4": ["p4", "p4"],
21
"e5": ["p5", "p1"]
22
}
23
}
Copied!
1
{
2
"_id": "8f8897ad-e07b-4e55-9dbe-61f6b9df85c5",
3
"label": "lane_divider",
4
"attributes": {
5
"raised": {
6
"value": "Yes"
7
},
8
}
9
"points": {
10
"p1": {"x": 0.286774, "y": 0.892502},
11
"p2": {"x": 0.285849, "y": 0.876888},
12
"p3": {"x": 0.286774, "y": 0.869081},
13
"p4": {"x": 0.288623, "y": 0.853878}
14
}
15
}
Copied!
1
{
2
"_id": "8f8897ad-e07b-4e55-9dbe-61f6b9df85c5",
3
"label": "Car",
4
"attributes" : {
5
"faces_visible": {
6
"value": ["right","back"]
7
}
8
},
9
"points": {
10
"p1": {"x": 0.17,"y": 0.58},
11
"p2": {"x": 0.26,"y": 0.58},
12
"p3": {"x": 0.26,"y": 0.49},
13
"p4": {"x": 0.17,"y": 0.49},
14
"p5": {"x": 0.24,"y": 0.51},
15
"p6": {"x": 0.35,"y": 0.52},
16
"p7": {"x": 0.35,"y": 0.36},
17
"p8": {"x": 0.25,"y": 0.37}
18
},
19
"front": {
20
"coordinates": ["p1","p2","p3","p4"]
21
},
22
"side": {
23
"coordinates": ["p2","p3","p5","p6"]
24
},
25
"back": {
26
"coordinates": ["p7","p8","p5","p6"]
27
}
28
}
Copied!
1
{
2
"_id": "e7e3353f-2ffe-432a-a14f-9cb9a6f4b735",
3
"label": "nose",
4
"attributes": {
5
"visible": {
6
"value": "Partially"
7
},
8
}
9
"points": {
10
"p1": { "x": 0.17, "y": 0.58, "label": 1 },
11
"p2": { "x": 0.26, "y": 0.63, "label": 2 },
12
"p3": { "x": 0.27, "y": 0.63, "label": 3 },
13
"p4": { "x": 0.29, "y": 0.59, "label": 4 },
14
"p5": { "x": 0.25, "y": 0.46, "label": 5 },
15
"p6": { "x": 0.22, "y": 0.42, "label": 6 }
16
}
17
}
Copied!
Last modified 3mo ago