AWS S3 Bucket
Upload Images from an AWS S3 bucket to Roboflow
When dealing with image data storage in AWS S3 and uploading to Roboflow, you generally have two options: using signed URLs or manually downloading images locally (via the AWS CLI) to upload them locally. The choice between these methods depends on your specific needs for data processing and management.
Signed URLs: This method is particularly advantageous if you want to avoid the extra step and time consumption associated with downloading images to your local machine. With a signed URL, you can directly upload the image data from S3 to the Roboflow API without ever having to store it locally. This results in faster processing and less load on your local system.
CLI Locally: There might be scenarios where you'd prefer to download the images to your local environment first. For instance, if you need to preprocess the images or manually check them before uploading to Roboflow, having local copies would be beneficial.
Selecting the right method will depend on your specific use-case requirements, like speed of data transfer, need for preprocessing, or manual inspection of images.
AWS CLI Setup
Before using the script, ensure you've set up AWS CLI with the necessary authentication credentials. This will allow you to access and manage the desired S3 bucket.
Configuring the AWS CLI
Once you've installed the AWS CLI, open a terminal or command prompt.
Run the following command:
You'll be prompted to enter your AWS credentials:
Option 1: Upload Via Signed URL:
You can generate signed URLs for your images in the S3 bucket by using boto3 in Python.
In the code snippet above, you need the name of your S3 bucket, the object name for the image in the S3 bucket, and the aws region. The signed URL of the image is generated and returned.
Building around this, we can generate a complete solution that pulls all the available objects in the S3 bucket, and then uploads them to Roboflow via the API. An outline for this solution can be seen below:
Option 2: Download Data Locally from AWS
To upload data from AWS, first install the awscli
command line tool. This tool allows you to interact with your AWS account on the command line. Once you have the command line tool installed, run the following command:
Replace mybucket
with the name of your bucket and folder_path
with the name of the folder or file you want to export. This comamnd will download an asset from AWS to your current working directory (.
).
Upload Data to Roboflow
Now that we have downloaded data, we can upload it to Roboflow either by using the Upload Web Interface or the Roboflow CLI.
See Also
Last updated