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

Payload

1
{
2
"reference_id":"001",
3
"data":{
4
"image_url":"https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1"
5
},
6
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
7
}
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
# Additional helper function to create a batch
13
def create_batch(BATCH_NAME):
14
base_url = f"https://api.playment.io/v1/projects/{PROJECT_ID}/batch"
15
DATA = {"name":BATCH_NAME}
16
response = requests.post(base_url, headers={'x-api-key': CLIENT_KEY}, json=DATA)
17
response_data = response.json()
18
if response.status_code >= 500:
19
raise Exception(f"Something went wrong at Playment's end {response.status_code}")
20
if 400 <= response.status_code < 500:
21
raise Exception(f"{response_data['error']['message']} {response.status_code}")
22
print(response_data)
23
return response_data
24
25
#method that can be used to call the job creation api
26
def create_job(project_id, data, x_api_key):
27
base_url = "https://api.playment.io/v1/projects/{}/jobs".format(project_id)
28
headers = {'x-api-key': x_api_key}
29
response = requests.post(base_url, headers=headers, json=data)
30
31
print(response.json())
32
if response.status_code >= 500:
33
raise Exception(response.text)
34
if 400 <= response.status_code < 500:
35
raise Exception(response.text)
36
return response.json()
37
38
if __name__ == "__main__":
39
#list of frames in a single job
40
image_url = "https://example.com/image_url_1"
41
42
#reference_id should be unique for each job
43
reference_id= "job1"
44
45
project_id = ''
46
x_api_key = ''
47
workflow_id = ''
48
batch_id = ''
49
50
51
job_data = {
52
'reference_id':reference_id,
53
'work_flow_id':workflow_id,
54
'data':{
55
'image_url':image_url
56
},
57
'batch_id': batch_id
58
}
59
60
response = create_job(project_id=project_id, data=job_data, x_api_key= x_api_key)
61
print(response)
62
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
"image_url":"https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
5
"maker_response" : {
6
"rectangles": {
7
"data": []
8
},
9
"polygons": {
10
"data": []
11
},
12
"lines": {
13
"data": []
14
},
15
"cuboids": {
16
"data": []
17
},
18
"landmarks": {
19
"data": []
20
}
21
}
22
},
23
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
24
}
Copied!
Each object in the data.maker_response.rectangles.data list will be an annotation object of the respective annotation type. For example:
Rectangle
Polygons
Lines
Cuboids
Landmarks
1
{
2
"_id": "0e6d895e-2484-439a-b62b-d8a0afb3d190",
3
"label": "Cat".
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!