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

Payload

{
"reference_id": "001",
"data": {
"image_url": "https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
"reference_data": {
"raster": {
"images": [
{
"image_url": "https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
"label": "camera 1"
},
{
"image_url": "https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
"label": "camera 2"
}
]
}
}
},
"work_flow_id": "2aae1234-acac-1234-eeff-12a22a237bbc"
}

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
import requests
import json
"""
Details for creating JOBS,
project_id ->> ID of project in which the job will be created
x_api_key ->> API key for authentication
workflow_id ->> The workflow in which the job will be created
batch_id ->> The batch in which job will be created
"""
# Additional helper function to create a batch
def create_batch(BATCH_NAME):
base_url = f"https://api.playment.io/v1/projects/{PROJECT_ID}/batch"
DATA = {"name":BATCH_NAME}
response = requests.post(base_url, headers={'x-api-key': CLIENT_KEY}, json=DATA)
response_data = response.json()
if response.status_code >= 500:
raise Exception(f"Something went wrong at Playment's end {response.status_code}")
if 400 <= response.status_code < 500:
raise Exception(f"{response_data['error']['message']} {response.status_code}")
print(response_data)
return response_data
#method that can be used to call the job creation api
def create_job(project_id, data, x_api_key):
base_url = "https://api.playment.io/v1/projects/{}/jobs".format(project_id)
headers = {'x-api-key': x_api_key}
response = requests.post(base_url, headers=headers, json=data)
print(response.json())
if response.status_code >= 500:
raise Exception(response.text)
if 400 <= response.status_code < 500:
raise Exception(response.text)
return response.json()
if __name__ == "__main__":
#list of frames in a single job
image_url = "https://example.com/image_url_1"
ref_image_url1 = "https://example.com/ref_image_url_1"
ref_image_url2 = "https://example.com/ref_image_url_2"
#reference_id should be unique for each job
reference_id= "job1"
project_id = ''
x_api_key = ''
workflow_id = ''
batch_id = ''
job_data = {
'reference_id':reference_id,
'work_flow_id':workflow_id,
'data':{
'image_url':image_url,
'reference_data': {
'raster': {
'images': [
{
'image_url': ref_image_url1,
'label': 'camera 1'
},
{
'image_url': ref_image_url2,
'label': 'camera 2'
}
]
}
}
},
'batch_id': batch_id
}
response = create_job(project_id=project_id, data=job_data, x_api_key= x_api_key)
print(response)

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:
{
"reference_id":"001",
"data":{
"image_url":"https://s3.aws.com/600x400/000/fff.jpg&text=Dummy+Image+1",
"maker_response" : {
"raster": {
"data": {
"legend": {
"#fdffd34": "Person 1",
"#f23334": "Car 1",
"#fd2d34": "Sky"
},
"url": "https://example.s3.ap-south-1.amazonaws.com/mask001.png"
}
}
}
},
"work_flow_id":"2aae1234-acac-1234-eeff-12a22a237bbc"
}
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.
Copy link
On this page
post
A JOB
Payload
Payload Definition
Code Example
Creating jobs with pre-labeled data