Registering new images or videos

After the external bucket is ready and you have populated it with images you need to notify Darwin which images Darwin should list, and for which dataset, this is done via a REST PUT request.

All REST endpoints in Darwin are using api keys for authentication, you can setup your own key here.

The following python scripts shows how to register a newly added image:

import requests

api_key = "your_key_here"

team_slug = "team_slug_here"
dataset_slug = "dataset_slug_here"
storage_name = "storage_name_here"

headers = {
    "Content-Type": "application/json",
    "Authorization": f"ApiKey {api_key}"
}

payload = {
    "items": [
        {   
          "type": "image",
          "key": "darwin/cars/2008_000074.jpg",
          "filename": "2008_000074.jpg"
        }
    ],
  "storage_name": storage_name
}

response = requests.put(
  f"https://darwin.v7labs.com/api/teams/{team_slug}/datasets/{dataset_slug}/data",
  headers=headers,
  json=payload
)

if response.status_code != 200:
    print("request failed", response.text)
else:
    print("success")

For more details, please refer to our API reference here.

Generating thumbnails

In cases where you prefer to generate thumbnails on your own, or when you are unable to give write access to V7 to your bucket, the payload changes slightly (notice thumbnail_key):

"items": [
    {
        "type": "image",
        "key": "darwin/cars/2008_000074.jpg",
        "thumbnail_key": "darwin/2008_000074_thumbnail.jpg"
        "filename": "2008_000074.jpg"
    }
]

We recommend using mogrify for thumbnail generation.

> mogrify -resize "356x200>" -format jpg -quality 50 -write thumbnail.jpg large.png