> ## Documentation Index
> Fetch the complete documentation index at: https://api-reference.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Dataset

# Overview

In this guide, we'll walk through the steps to upload your 2D image data to Nucleus.

1. Create `Dataset` for `DatasetItems`
2. Create image `DatasetItems`
3. Upload `DatasetItems` to `Dataset`
4. Update metadata

# Creating a `Dataset`

Get started by creating a new `Dataset` to which to upload your 2D data. If you do have an existing `Dataset`, you can retrieve it by its dataset ID. You can list information about all of your datasets using `NucleusClient.datasets`, or extract it from the Nucleus dashboard's URL upon clicking into the Dataset.

```python Create new Dataset theme={null}
from nucleus import NucleusClient

client = NucleusClient(YOUR_API_KEY)

dataset = client.create_dataset(YOUR_DATASET_NAME)
```

# Creating Image `DatasetItems`

Next, we'll upload `DatasetItems` via API.

When uploading items via API, you'll first need to construct `DatasetItem` payloads. The best way to do so is using the Python SDK's `DatasetItem` constructor, which takes in a few parameters:

| Property | Type | Description |
| :- | :- | :- |
| image\_location | string (**required**) | Local path or remote URL to the image. For large uploads we require the data to be stored within AWS S3, Google Cloud Storage, or Azure Blob Storage for faster concurrent & asynchronous processing. See [here](https://scale.com/docs) for info on how to grant Scale access to your remote data. |
| reference\_id | string (**required**) | A user-specified identifier for the image. Typically this is an internal filename or any unique, easily identifiable moniker. |
| metadata | dict | Optional metadata pertaining to the image, e.g. time of day, weather. These attributes will be queryable in the Nucleus platform. Metadata can be updated after uploading (via reference ID). |
| pointcloud\_location | string | This parameter should not be supplied for 2D items! `DatasetItems` can also house lidar pointclouds; please check out our 3D guide for more info. |

To keep your data from being uploaded to Scale, see [Privacy Mode](https://api-reference.scale.com/docs/nucleus/privacy-mode.md).

```python Example DatasetItem Creation theme={null}
from nucleus import DatasetItem

accessible_urls = [
    "http://farm1.staticflickr.com/107/309278012_7a1f67deaa_z.jpg",
    "http://farm9.staticflickr.com/8001/7679588594_4e51b76472_z.jpg",
    "http://farm6.staticflickr.com/5295/5465771966_76f9773af1_z.jpg",
    "http://farm4.staticflickr.com/3449/4002348519_8ddfa4f2fb_z.jpg",
]
reference_ids = ['107', '8001', '5925', '3449']
metadata_dicts = [
  	{'indoors': True},
  	{'indoors': True},
  	{'indoors': False},
  	{'indoors': False},
]

dataset_items = []
for url, ref_id, metadata in zip(accessible_urls, reference_ids, metadata_dicts):
    item = DatasetItem(image_location=url, reference_id=ref_id, metadata=metadata)
    dataset_items.append(item)
```

> [!WARNING]
>
> **Maximum Image Size**
>
> Note that your images must be at most 5,000px by 5,000px. For larger images, we recommend downsizing such that they fall within this size range.

# Uploading `DatasetItems` to Nucleus

We'll upload to the `Dataset` created earlier in this guide. You can always retrieve a `Dataset` by its dataset ID. You can list all of your datasets' IDs using `NucleusClient.datasets`, or extract one from the Nucleus dashboard's URL upon clicking into the `Dataset`.

```python Get existing Dataset theme={null}
from nucleus import NucleusClient

client = NucleusClient(YOUR_API_KEY)

dataset = client.get_dataset(YOUR_DATASET_ID)
```

With your images and dataset ready, you can now upload to Nucleus using `Dataset.append`.

```python Example upload to Dataset theme={null}
job = dataset.append(items=dataset_items)
job.sleep_until_complete()
```

# Large Batch Uploads

`Dataset.append` always processes uploads asynchronously and returns an `AsyncJob`. The concurrent processing dramatically increases upload throughput.

> [!NOTE]
>
> For large uploads, we recommend storing your images remotely (e.g. in S3, GCS, or Azure Blob Storage) rather than uploading local files.

```python theme={null}
job = dataset.append(items=dataset_items)

# async jobs will run in the background, poll using:
job.status()

# or block until job completion using:
job.sleep_until_complete()
```

# Updating Metadata

By setting the `update=True` in `Dataset.append`, your upload will overwrite metadata for any existing item with a shared `reference_id`.

For instance, in our example we uploaded an item with reference ID `107`. We can overwrite this item's metadata to include a new key-value pair as follows:

```python Example metadata update theme={null}
updated_item = DatasetItem(
  	image_location="http://farm1.staticflickr.com/107/309278012_7a1f67deaa_z.jpg",
  	reference_id="107",
  	metadata={"indoors": True, "room": "living room"}
)

job = dataset.append(
  	items=[updated_item],
  	update=True # overwrite on reference ID collision
)
job.sleep_until_complete()
```

We highly recommend adding as much metadata as possible! Metadata is queryable in the Nucleus dashboard and can unlock many data exploration and curation workflows. See our [metadata guide](https://api-reference.scale.com/docs/nucleus/upload-metadata.md) for more info.

# Dashboard Upload

Using the [Nucleus dashboard](https://dashboard.scale.com/nucleus), you can upload directly from disk or [import an existing Scale or Rapid labeling project](https://api-reference.scale.com/docs/nucleus/ingest-from-labeling.md).

![Uploading local files from the dashboard (creates a new Dataset).](https://mintcdn.com/scale-full-docs/0LAM4ucKzAG9Dmk0/assets/nucleus/442b08a-ui-upload.webp?fit=max\&auto=format\&n=0LAM4ucKzAG9Dmk0\&q=85\&s=ea00ab554e8517743fdefb4608679c3b)

Uploading local files from the dashboard (creates a new Dataset).
