Parameters:

  • instance_list: A Python list with the instances for the file to update. Required for image type files.
  • frame_packet_map: A Python Dictionary with the instance_list per frame of a video. Required for video type images. To read more about this formate check: Understanding Diffgram's File Format
  • overwrite: Boolean value. If true, it will archive all the existing instances on the file and set only the instances seen on the new given instance_list or frame_packet_map

Description

Updates an existing file with new instances, all the instances should follow the schema described in Understanding Diffgram's File Format .

❗️

Warning: Overwriting is a Destructive Action

When you set the overwrite=True flag on this method. All existing instances will be deleted, this means any human made labels made on the UI will not exist anymore and can cause unexpected data loss if used on the wrong file or at the wrong moment in the training pipeline. Please use with caution.

Examples

In the following example we show how to upload a sample frame_packet_map to a video:

from diffgram.core.core import Project

def build_frame_packet_map():
    result = {}

    for i in range(253):
        result[i] = [
            {
                'type': 'box',
                'name': 'hot dog',
                'x_min': 100,
                'y_min': 100,
                'x_max': 200,
                'y_max': 200,
                'frame_number: i,
                'number': 1 # The sequence number.
            }
        ]
    return result

project = Project(project_string_id = "test_project",
                  client_id = "client_id",
                  client_secret = "client_secret")

file = project.file.get_by_id(<your_video_file_id>)

f_packet_map = build_frame_packet_map()

# Update video without removing existing instances.
file.update(frame_packet_map=f_packet_map)

# Update video and remove all existing instances.
file.update(frame_packet_map=f_packet_map, overwrite=True)

https://github.com/diffgram/diffgram/blob/master/sdk/diffgram/file/test_existing_instances.py#L130


Did this page help you?