Skip to main content
Encord’s SDK supports importing labels/annotations for your data in the COCO format. You can also import your COCO labels/annotations as predictions on your Projects.
This guide assumes your files were already imported into Encord and a Project containing the data has been created.
  1. Save import.py, replacing the following variables:
    • SSH_PATH with the full path to your private key.
    • PROJECT_ID with the unique ID of the Project containing the data units you want to import labels for.
    • COCOimportfile.json with the full path of the COCO file containing the labels you want to import.
  2. If necessary, modify the matching logic that maps COCO image IDs to Encord frame indices. This is particularly important in cases where filenames in the COCO file do not directly match those in the Encord Project or when multiple files have the same name.
The following import.py script is configured to import labels into single images with unique names and assumes that the category names in the COCO file match the names of your Ontology objects. It matches each COCO image’s file_name to the title of a data unit in the Project. COCO files exported from Encord also include image_title or video_title fields, and the script uses those when they are present. In practice, you must implement your own matching logic. An example where filenames in the COCO file do not directly match those in the Encord Project is provided below.