Upload a Dataset
Upload a structured dataset of images and annotations to a Roboflow project with the Python SDK.
This page covers bulk import of an existing labeled dataset (images plus their annotations) using the Python SDK, the HTTP API, or the CLI. To upload and manage individual images through the API, see Manage Images.
Python SDK
Workspace.upload_dataset() uploads a structured dataset (images + matching annotations) to a Roboflow project. The project will be created if it doesn't exist; otherwise the new images get added to the existing project.
import roboflow
rf = roboflow.Roboflow(api_key="YOUR_API_KEY")
workspace = rf.workspace()
workspace.upload_dataset(
"./dataset/", # path to a structured dataset directory
"my-detector", # project id (created if it doesn't exist)
num_workers=10,
project_license="MIT",
project_type="object-detection",
batch_name=None,
num_retries=0,
is_prediction=False, # True for model-generated annotations awaiting review
)Parameters
dataset_path(str) - path to the dataset root.project_name(str) - destination project's id. Created if it doesn't exist.num_workers(int, default10) - concurrent uploads. We recommend not exceeding 25.project_license(str, default"MIT") - license for a newly-created project. Set to"Private"for private projects.project_type(str, default"object-detection") - type for a newly-created project. Ignored if the project already exists.batch_name(str, optional) - group these uploads under a named batch. Useful for tracking the source of a labeling round.num_retries(int, default0) - retry transient upload failures.is_prediction(bool, defaultFalse) - set toTrueto upload annotations as model predictions awaiting review rather than ground truth.
Where predictions land
When you save a prediction on an image that is still in an upload batch, Roboflow moves that image into a review job for the batch. Open the job to approve or fix the labels before they become ground truth.
If the image is already assigned to an annotation job, it stays in that job.
Expected directory layout
For a COCO dataset:
The folder that holds each image sets its split. Only these exact folder names count: train, training, valid, validation, val, test, and testing. Case does not matter, and file names are ignored, so an image named test_image.jpg does not land in the test split and a folder named train2017 sets no split. When no folder matches, the image falls back to the upload's default split: for zip uploads that is the split value in your request, which defaults to train.
For VOC, drop matching .xml files alongside each image. For YOLO, drop matching .txt files plus a data.yaml describing the class list.
Note on SHA-256 dedup (v1.3.6+)
As of roboflow 1.3.6, the SDK uploads original image bytes rather than re-encoding via Pillow. This brings parity with the web uploader and lets the Roboflow server deduplicate uploads by SHA-256 - re-uploading the same image (e.g. into a different batch) succeeds without consuming additional storage credits.
HTTP API
Upload a Dataset Zip
Upload a whole dataset as one ZIP file. Roboflow processes it in the background, so you do not hold a connection open while it runs. The ZIP can hold images and annotations in any supported format (ex: COCO, YOLO, Pascal VOC). For classification, folder names become class labels.
The upload takes three steps:
Start the upload. The response has a signed URL and a
taskId.PUT the ZIP to the signed URL with
Content-Type: application/zip. Processing starts when the upload finishes.Poll the task until its status is
completedorfailed.
Starts a dataset ZIP upload and returns a signed URL to PUT the ZIP to, plus a task ID to poll. Processing starts when the upload to the signed URL finishes. The ZIP can hold images and annotations in any supported format (ex: COCO, YOLO, Pascal VOC); for classification, folder names become class labels. Limits are 8 GB of extracted files and 100,000 files. Requires image:create.
Roboflow API key or OAuth access token.
Workspace URL slug.
Project URL slug.
Split for images whose folder does not set one.
trainPossible values: Batch name for the uploaded images. A ZIP with annotations creates one annotation job with this name, or "Uploaded via API" when you leave it out.
Tags to add to each uploaded image or video.
Replace the annotations on images that are already in the project. By default those images keep their annotations. Classification projects always replace the label and reject false with 400.
falseSuccessful response.
Task ID to poll for status.
URL to PUT the ZIP file to, with Content-Type application/zip. It expires after one hour.
annotationOverwrite is false in a classification project.
Authentication is missing or invalid.
The credential does not have access to this resource.
The resource does not exist or is not accessible.
The request rate is too high.
POST /{workspace}/{project}/upload/zip HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 62
{
"split": "train",
"batchName": "april-batch",
"tags": [
"outdoor"
]
}{
"taskId": "abc123",
"signedUrl": "https://storage.googleapis.com/roboflow-uploads/zip-uploads/abc123.zip?X-Goog-Signature=..."
}The signed URL is on Google Cloud Storage, not the Roboflow API, so send the file there without your API key:
By default, an image already in the project keeps its annotations, and the ZIP's annotation for it is skipped. Set annotationOverwrite to true to replace them.
A ZIP with annotations lands in one annotation job named after batchName. Every upload gets its own job, even when you reuse a name. If the workspace has Review Mode on, the images wait in Review and join the dataset once a reviewer approves them.
Returns the status of a dataset ZIP upload. Poll it until status is completed or failed. Requires image:create.
Roboflow API key or OAuth access token.
Workspace URL slug.
Asynchronous task ID.
Successful response.
created until the ZIP arrives, then running, then completed or failed.
The request is invalid.
Authentication is missing or invalid.
The credential does not have access to this resource.
The task does not exist or belongs to another workspace.
The request rate is too high.
GET /{workspace}/upload/zip/{taskId} HTTP/1.1
Host: api.roboflow.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
{
"status": "completed",
"progress": {
"current": 250,
"total": 250
},
"result": {
"uploaded": 248,
"duplicates": 0,
"annotated": 248,
"videosStaged": 0,
"videoIds": [],
"uploadErrors": [
{
"path": "train/broken.jpg",
"error": "Unsupported image format"
}
],
"annotationErrors": [],
"warnings": [],
"chunkCount": 3,
"failedChunks": 0
}
}PDFs inside the ZIP are skipped with an unsupported-format warning. Videos are skipped the same way, except in Action Recognition projects.
In an Action Recognition project, each MP4 or MOV video up to 3 GB in the ZIP is added as a video, like a video upload. Images in the ZIP are skipped with a warning. Videos get the upload's tags, batch, and split, and a train, valid, or test folder sets the split the same way it does for images. Use each ID in result.videoIds to check that video's status. Video labels inside the ZIP are not imported.
CLI
You can upload datasets with images and/or annotations using the Roboflow CLI.
We have prepared a video that walks through how to upload a dataset:
Upload a Directory
Use roboflow image upload with a directory path to bulk-upload a dataset with parallel per-image uploads:
Or use the shorthand alias:
The CLI auto-detects whether the path is a file, directory, or .zip file. A directory triggers a bulk import with parallel per-image uploads unless you use --zip-upload.
Options
-p, --project
Project ID (required)
-c, --concurrency
Number of parallel uploads (default: 10)
-b, --batch
Batch name for grouping uploads
-r, --retries
Retry failed uploads N times (default: 0)
-s, --split
Override split for all uploaded images
Example with options:
Upload a Zip File
Use zip uploads for larger datasets or when your dataset is already packaged as a .zip file. Zip uploads use Roboflow's asynchronous zip upload flow. By default, the CLI uploads the zip file and waits for processing to finish.
This is the same flow documented in HTTP API above. The CLI handles the signed URL upload and task polling for you.
To upload an existing zip file:
To zip a local directory client-side and upload it with the async zip flow, use --zip-upload with the primary command:
Options for Zip Uploads
-p, --project
Project ID (required)
--zip-upload
Zip a directory client-side and upload it with the async zip upload flow
--no-wait
Return immediately after the zip is uploaded instead of waiting for processing to finish
-b, --batch
Batch name for grouping uploads
-s, --split
Split set: train, valid, or test
-t, --tag
Comma-separated tag names
Example with zip upload options:
To start processing and return a task ID immediately:
The JSON response includes the asynchronous task ID:
Zip uploads do not support --is-prediction. Use the regular per-image upload flow for prediction uploads.
Supported Project Types
You can upload data for the following project types:
Object Detection
Single-Label Classification
Multi-Label Classification
Instance Segmentation
Semantic Segmentation
Keypoint Detection
Supported data.yaml Formats
The CLI supports both list-style and key-value pair formatted class name mappings in data.yaml files during dataset uploads:
OR
JSON Output
For automation, use --json:
MCP Server
Connect your AI agent to the MCP Server and it can upload a dataset with these tools: The zip holds images only, so labels are saved in a second step.
image_upload
Upload local image files to a project via a zip. Images only, no annotation files.
image_upload_status
Check the status of an image zip upload task.
annotations_save
Save an annotation for an image that is already uploaded.
Next steps
Label any unannotated images so they can be used for training. See Introduction to Roboflow Annotate.
Turn your images into a trainable snapshot. See Create a Dataset Version.
Last updated
Was this helpful?