How to Use S3 in Your Computer Vision Pipeline

Many teams already use AWS S3 as the data storage for their camera footage and inspection images. Today I'll show you how to use S3 in your computer vision pipeline with Roboflow: grant read access to a bucket, mirror its images into a Roboflow project, label them, train an RF-DETR model (opens in a new tab), and run that model on new images as they arrive in S3.
Your images stay in S3 throughout this process. Roboflow copies the files that match your filters, skips files it has already imported, and picks up new files each day.
Why connect S3 to a computer vision pipeline
A production computer vision system needs a steady flow of new images. Cameras on a production line, drones over a field, and dashcams on a fleet all write new data every day, and the model gets better when a sample of that data is labeled and added to training.
Now it's easier to move the right images from your S3 bucket to a labeling tool on a regular basis. Roboflow Datasources (opens in a new tab) handles that sync for you:
- A reusable credential gives Roboflow read access to one bucket.
- File filters choose which objects to import.
- A daily schedule picks up new files automatically.
- Files already in your workspace, matched by bucket location and hash, are not imported again, which keeps egress costs down.
- JSON sidecar files next to each image bring metadata such as camera ID, site, or capture time into Roboflow, where you can search and filter on it.
What you need
- An AWS account with an S3 bucket that holds JPEG, PNG, BMP, WebP, or AVIF images.
- Permission to create an IAM role and policy in that AWS account.
- A free Roboflow account and a project for your task, for example an object detection project.
- A browser. Python is optional and only needed for the inference example at the end.
Step 1: Organize your bucket
Datasources can mirror a whole bucket or only part of it, so a clear folder structure makes the rest of the setup simpler. Group images by source, such as camera, line, or site:
my-inspection-bucket/
images/
line-3/
cam-01_2026-11-30_0800.jpg
cam-01_2026-11-30_0800.json
cam-02_2026-11-30_0800.jpg
cam-02_2026-11-30_0800.jsonThe .json files are optional metadata sidecars. When a sidecar has the same base name as an image, Roboflow imports its contents as metadata for that image:
{
"camera_id": "cam-01",
"site": "plant-2",
"capture": { "shift": "day", "line_speed": 42 }
}Nested keys are flattened with dot notation, so capture.shift and capture.line_speed become searchable fields. Each sidecar must be valid JSON and no larger than 256 KB.
Step 2: Give Roboflow read access to the bucket
Roboflow supports three ways to read an S3 bucket. Use Assume Role unless you have a reason not to. It avoids long-lived access keys, and it is the method Roboflow and AWS recommend. Full details are in the AWS S3 credentials guide (opens in a new tab).
- In Roboflow, open Credentials in your workspace settings, click Add Credential, and choose the AWS Assume Role credential type. Leave this window open.
- Copy the Roboflow AWS principal ARN and the External ID shown in the form.
- In the AWS IAM Roles console (opens in a new tab), create a new role for Roboflow.
- Give the role this trust policy, replacing the placeholders with the values from step 2:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "<roboflow-principal-arn>"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "<your-external-id>"
}
}
}
]
}- Attach a permissions policy that grants read access to your bucket only:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket", "s3:GetBucketLocation"],
"Resource": "arn:aws:s3:::your-bucket-name"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectTagging"],
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}- Copy the role ARN, paste it into the Roboflow credential form, and save the credential.
The role can list and read objects in one bucket and nothing else. It cannot write, delete, or reach your other buckets.
If your team prefers access keys, create a dedicated IAM user with the same bucket-scoped policy and choose the AWS IAM credential type instead. Enterprise customers can also grant access through a bucket policy. Both options are covered in the Datasource policy examples (opens in a new tab).
Step 3: Create a Datasource for your bucket
Open Datasources in your workspace settings and create a new Datasource. The form has two tabs.
On the Connection tab:
- Name: a label you will recognize later, such as
plant-2-line-3. - Provider: S3.
- Bucket: the bucket name only, for example
my-inspection-bucket. A value with a folder path after the name is rejected. You will narrow the selection with file filters in the next step. - Region: the AWS region of the bucket.
- Credential: the credential you saved in Step 2.
Step 4: Choose which images to sync and where they go
On the Mirror Configuration tab, set the import destination and file filters.
Import Destination: choose Workspace, then use the Import into dropdown to select your project. Mirrored images land in your workspace Asset Library (opens in a new tab) and are also added to that project, ready for labeling. Each Datasource imports to one destination, so create a second Datasource if another project needs images from the same bucket.
File Filters: by default, every supported image in the bucket is imported. Add glob patterns to limit the import. A single * matches within one folder level, and ** matches across levels.
| Pattern | What it imports |
|---|---|
images/line-3/*.jpg | JPEG files directly inside line-3 |
images/line-3/** | Every file anywhere under line-3 |
images/**/cam-01* | Files from camera 01 across all lines |
Start with one camera or one line. A narrow first import is faster to inspect and keeps labeling focused on the images your model needs.
If the bucket also holds MP4 or MOV video, Roboflow mirrors those files to the Asset Library too, up to 3 GB each. Use an image-only pattern such as **/*.jpg to leave video out. For video-heavy buckets, see how to turn videos in S3 into a computer vision dataset.
Step 5: Run the first sync and turn on the daily schedule
Save the Datasource, then click the play button next to it in the Datasources list to start the first sync. Roboflow crawls the bucket, imports matching images and sidecar metadata, and reports the results of the run.
When the sync finishes, click the eye icon next to the Datasource to open the Asset Library filtered to the images it imported. Search by metadata (for example, every image where site is plant-2), by tag, by natural language, or by visual similarity to find the examples worth labeling first.
To keep the project current, open Scheduling under Mirror Configuration and check Run automatically on a daily schedule. The Datasource then syncs every 24 hours and imports only what is new. A few related settings control how changes in the bucket are handled:
- When an image in S3 is replaced with a newer version, Roboflow re-imports it by default.
- When a sidecar file changes, Roboflow re-syncs that image's metadata. By default, bucket values win when they conflict with metadata someone edited in Roboflow, and you can change that strategy.
- Files deleted from the bucket stay in Roboflow by default. You can enable orphan removal to remove them, as long as no project uses them.
You can still trigger a sync by hand between scheduled runs, for example after uploading a new batch of images to S3. Manual syncs have a 15-minute cooldown and a limit of 10 per hour. Scheduled syncs do not.
Step 6: Label your images
Open your project and start labeling the mirrored images. Auto Label uses foundation models to draw a first pass of boxes or masks from your class names, so your team reviews and corrects labels instead of drawing every one by hand. After you approve your first batch of annotations, Roboflow trains an Instant Model that you can use to auto label the next batch.
Use the metadata from your sidecars to build a balanced first dataset: a mix of cameras, shifts, and sites gives the model a better view of the conditions it will face in production.
Step 7: Train an RF-DETR model
When you have a few hundred labeled images, generate a dataset version. Roboflow splits the images into train, validation, and test sets and applies the preprocessing and augmentation you choose, such as auto-orient and resize.
Then train a model (opens in a new tab) on that version. For object detection and instance segmentation, choose RF-DETR, Roboflow's real-time vision model for detection and segmentation. Train from the default public checkpoint, which starts from weights pretrained on Microsoft COCO and usually reaches a good result faster than training from scratch. Training runs on Roboflow's cloud GPUs, so there is nothing to install.
When training finishes, review mean average precision (mAP), precision, and recall for each class. If a class underperforms, use the Asset Library to find more examples of it in your mirrored S3 data, label them, and train a new version. The Datasource keeps importing new images, so each round of labeling can draw on the latest data from your cameras.
RF-DETR is released under the Apache 2.0 license, so you can ship it in commercial products, including self-hosted deployments, without a separate license fee.
Step 8: Run your model on new S3 images
With a trained model, the same Datasource can drive inference as well as training data.
To process new images automatically, build a Roboflow Workflow that runs your RF-DETR model, then attach it to the Datasource. On the Datasources page, open the Workflow runs section, click Add workflow run, choose On Sync under Run when, and select your Datasource. Each time the Datasource syncs, Batch Processing (opens in a new tab) runs the Workflow over the newly imported images. You can write the results back to the Asset Library as tags or metadata, which makes predictions searchable and helps you find hard examples for the next round of labeling. The Workflow must have exactly one image input.
To process a large existing archive in S3 without importing it, run Batch Processing directly against the bucket. See how to use Roboflow Batch Processing on images stored in AWS S3.
To call the model on demand from your own code, use the Serverless Hosted API (opens in a new tab):
pip install inference-sdk supervisionimport os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.getenv("ROBOFLOW_API_KEY"),
)
# model_id is "project-name/version", for example "line-3-defects/1"
result = client.infer("image.jpg", model_id="your-project/1")
image = cv2.imread("image.jpg")
detections = sv.Detections.from_inference(result)
box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()
annotated = box_annotator.annotate(scene=image.copy(), detections=detections)
annotated = label_annotator.annotate(scene=annotated, detections=detections)
cv2.imwrite("annotated.png", annotated)Set your Roboflow API key as the ROBOFLOW_API_KEY environment variable rather than writing it into the script. To run the same model on your own hardware, on-prem or at the edge, point api_url at a Roboflow Inference (opens in a new tab) server instead.
Set up the S3 connection from an AI assistant
If you work in ChatGPT, Claude Code, Cursor, or another agent that supports the Model Context Protocol, the Roboflow MCP server (opens in a new tab) can set up the same pipeline from a prompt. Its connect_cloud_storage tool creates the credential and Datasource and starts the first run, and datasource_job_get reports the results. This is useful when you manage several buckets or want the setup recorded in your agent's history.
S3-compatible storage and other clouds
Datasources also work with storage that implements the S3 API, including Cloudflare R2, Backblaze B2, Wasabi, DigitalOcean Spaces, MinIO, and more than a dozen other providers. Choose S3 as the provider, enter the provider's S3 API endpoint, and set the region to auto or the provider's region value. The endpoint must be reachable from the public internet. Google Cloud Storage and Azure Blob Storage are supported as separate providers. The Datasources documentation (opens in a new tab) lists every supported provider and its endpoint format.
When to use a one-time import
Datasources are the right choice for any bucket you want to sync more than once. For a single import of a fixed set of images, such as moving an archived dataset into a new project, Roboflow also supports one-time uploads from S3 (opens in a new tab) with signed URLs or a local download.
Get started
Connecting S3 to Roboflow takes a credential, a Datasource, and a sync. From there, new images flow into labeling, training, and inference on a schedule you control. Create a free Roboflow account to connect your first bucket.