Low level method to send and update both Annotations and Raw Data


Long Running Operation

This operation only returns the input_id. Inputs are processed in the background by our distributed workers. Depending on factors such as type of file, account type, and system load, your file may be available in Diffgram almost immediately or may take several hours.

Example use cases

  • Send predictions to be corrected by humans or validated
  • Send existing annotation data to act as starting point for annotations
  • Send just the raw data. (instance_list may be empty).

Send Existing Instances and Raw Data (SDK)

You can use this endpoint to send instances and update existing files labels, and attributes. Just send any new data on the instance_list fields, or on the frame_packet_map field in the case of video.

Example of sending instances with the SDK


Label Names Are only supported on the SDK, Not On Direct HTTP Calls

When ingesting pre-labeled data using direct HTTP calls, you need to provide the label_file_id key on each of the instances instead of the label name (name key on the example). The Python SDK has the ability to obtain the label_file_id from the label name, that's why the below examples do not include a label_file_id key on the instance data payload.

instance_alpha = {
  'type': 'box',
  'name': 'cat',
  'x_max': 128, 
  'x_min': 48,
  'y_min': 97,
  'y_max': 128

instance_bravo = {
  'type': 'box',
  'name': 'cat',
  'x_max': 128, 
  'x_min': 1,
  'y_min': 1,
  'y_max': 128

# Combine into image packet

image_packet = {
  'instance_list' : [instance_alpha, instance_bravo],
  'media' : {
    'url' : "https://www.readersdigest.ca/wp-content/uploads/sites/14/2011/01/4-ways-cheer-up-depressed-cat.jpg",
    'type' : 'image'
result = project.file.from_packet(image_packet)

Example for Sending Instances with python requests.


Danger: mode='update_with_existing' and 'update'

The default mode='update' will add any of the provided instances in the instance_list parameter and will not overwrite data. However using update_with_existingis a destructive action and might remove instances if they are not provided on the instance list.

Think about update mode as "appending" new instances to the file and update_with_existing mode as "replacing" all instances on the file with the new ones provided.

import base64
import requests

diffgram_client = {
    "host": "<MY_DIFFGRAM_HOST>",
    "project_string_id":  "<MY_DIFFGRAM_PROJECT_STRING_ID>",
    "client_id":  "<MY_DIFFGRAM_CLIENT_ID>",
    "client_secret":  "<MY_DIFFGRAM_CLIENT_SECRET>",
auth = base64.b64encode((diffgram_client['client_id'] + ":" + diffgram_client['client_secret']).encode())
body = {
	'file_id': '<THE FILE ID TO UPDATE>',
  'instance_list': 'The new instances or existing instance list to update',
  'frame_packet_map':  'The new instances or existing instance list to update (for video only)',
  'mode': 'update', # Update will append, use update_with_existing to delete existing instances and replace them.
headers = {
    "accept": "application/json",
    "content-type": "application/json",
    "authorization": f"Basic {auth.decode()}"
url = f"{diffgram_client['host']}/api/v1/walrus/project/{diffgram_client['project_string_id']}/input/packet"
response = requests.post(url, json=body, headers=headers)


For reference on how to attach attributes to the instance list check: Uploading/Updating Files With Attributes

Click Try It! to start a request and see the response here!