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
"reference_data": {
6
"raster": {
7
"images": [
8
{
9
"image_url": "https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
10
"label": "camera 1"
11
},
12
{
13
"image_url": "https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
14
"label": "camera 2"
15
}
16
]
17
}
18
}
19
},
20
"work_flow_id": "2aae1234-acac-1234-eeff-12a22a237bbc"
21
}
Copied!

Payload Definition

Key
Type
Description
data.reference_data
Object
The reference_data object contains an additional list of images that can be used as a reference while annotating the primary image.
This is an optional key based on your requirement.
data.reference_data.raster.images is an array of reference images where each object has 2 keys :
image_url - URL of the image
label- Name of the image.
data.image_url
string
URL of the image.

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
image_url = "https://example.com/image_url_1"
28
ref_image_url1 = "https://example.com/ref_image_url_1"
29
ref_image_url2 = "https://example.com/ref_image_url_2"
30
31
#reference_id should be unique for each job
32
reference_id= "job1"
33
34
project_id = ''
35
x_api_key = ''
36
workflow_id = ''
37
batch_id = ''
38
39
40
job_data = {
41
'reference_id':reference_id,
42
'work_flow_id':workflow_id,
43
'data':{
44
'image_url':image_url,
45
'reference_data': {
46
'raster': {
47
'images': [
48
{
49
'image_url': ref_image_url1,
50
'label': 'camera 1'
51
},
52
{
53
'image_url': ref_image_url2,
54
'label': 'camera 2'
55
}
56
]
57
}
58
}
59
},
60
'batch_id': batch_id
61
}
62
63
response = create_job(project_id=project_id, data=job_data, x_api_key= x_api_key)
64
print(response)
65
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
"raster": {
7
"data": {
8
"legend": {
9
"#fdffd34": "Person 1",
10
"#f23334": "Car 1",
11
"#fd2d34": "Sky"
12
},
13
"url": "https://example.s3.ap-south-1.amazonaws.com/mask001.png"
14
}
15
}
16
}
17
},
18
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
19
}
Copied!
The object at the end ofdata.maker_response.raster.data.url should be a PNG file with four 8-bit channels. The first 3 channels are R, G & B respectively. The hex code for these RGB values for any pixel should map to a class or instance based on thelegend object. Un-labeled pixels should have each channel as 0.
Last modified 3mo ago