Upload an Annotation

Upload an annotation to Roboflow.

Linux or macOS

Attaching a VOC XML annotation to an image with ID abc123 in the your-dataset dataset called YOUR_ANNOTATION.xml:

cat YOUR_ANNOTATION.xml | curl -d @- \
"https://api.roboflow.com/dataset/your-dataset/annotate/abc123?\
api_key=YOUR_KEY&\
name=YOUR_ANNOTATION.xml"

Attaching a Darknet TXT annotation to an image with ID abc123 in the your-dataset dataset called YOUR_ANNOTATION.txt using a json labelmap - in this case we need to send the contents of the annotation file in a json instead of just sending it as the body.

#!/bin/bash
# store the annotation as a json-compatible string
txt_content=$(cat YOUR_ANNOTATION.txt | sed 's/\\/\\\\/g; s/"/\\"/g; s/$/\\n/' | tr -d '\n')
# create a json string with the annotation file and the label map [0=flower, 1=leaf]
json_payload="{ \"annotationFile\": \"$txt_content\", \"labelmap\":{\"0\":\"flower\", \"1\":\"leaf\"} }"

# upload the annotation + labelmap
echo $json_payload | curl -H "Content-Type: application/json" -d @- \
"https://api.roboflow.com/dataset/cultura-pepino-dark/annotate/abc123?\
api_key=YOUR_KEY&\
name=YOUR_ANNOTATION.txt"

Windows

You will need to install curl for Windows. The easiest way to do this is to use the git for Windows installer which also includes the curl command line tool when you select "Use Git and optional Unix tools from the Command Prompt" during installation.

Then you can use the same command as above.

Last updated