Upload boundingBoxes via Ingestion API

Hi!

I have a FOMO model that produces bounding boxes (classifications in a section of the image) and I’m wondering is there’s a way to send these bounding boxes to Edge impulse via the ingestion API for a single frame, something like this:

    bounding_boxes = [
                 {'height': 8, 'label': 'cat_face', 'value': 0.6261171698570251, 'width': 8, 'x': 216, 'y': 112}
    ]
    # Metadata containing bounding box information
    metadata = {
        "boundingBoxes": bounding_boxes
    }

    files = {
        'data': (filename, image_bytes, 'image/jpeg'),
    }
    headers = {
        'x-label': 'cat_face',
        'x-api-key': api_key,
        'x-metadata': json.dumps(metadata),  # Sending metadata as a header
        'x-disallow-duplicates': 'true'
    }

    # Send POST request
    response = requests.post(url, files=files, headers=headers)
1 Like

Hi @nicosandller

Yes you can you need to send it as part of a post request in the x-metadata:

"version": 1,
    "files": [
        {
            "path": "cubes.23im33f2.jpg",
            "category": "testing",
            "label": {
                "type": "label",
                "label": "cubes"
            },
            "metadata": {
                "version": "2023-1234-LAB"
            },
            "boundingBoxes": [
                {
                    "label": "green",
                    "x": 105,
                    "y": 201,
                    "width": 91,
                    "height": 90
                },
                {
                    "label": "blue",
                    "x": 283,
                    "y": 233,
                    "width": 86,
                    "height": 87
                }
            ]
        }

See more details in the docs:

Best

Eoin

1 Like

Thanks @Eoin!

I tried sending your example on x-metadata but kept getting these kinds of errors:

['Metadata is not valid: Value for metadata key "files" is not of type string']

After parsing files into str I was able to upload the image and got all the “files” value on the image metadata under a “files” field which is not what I expected.

I ended up just passing all the bounding box data on different keys and sending it to x-metadata to use for debugging and relabeling which helps (attached image)


, but I was thinking edge impulse would pick up the metadata and use it to display the boxes on the image.