Upload an Image

You can upload images to Roboflow projects using the web interface, Python SDK, REST API, and CLI.

Upload to an Existing Project

from roboflow import Roboflow

# Initialize the Roboflow object with your API key
rf = Roboflow(api_key="YOUR_PRIVATE_API_KEY")

# Retrieve your current workspace and project name
print(rf.workspace())

# Specify the project for upload
# let's you have a project at https://app.roboflow.com/my-workspace/my-project
workspaceId = 'my-workspace'
projectId = 'my-project'
project = rf.workspace(workspaceId).project(projectId)

# Upload the image to your project
project.upload("UPLOAD_IMAGE.jpg")

"""
Optional Parameters:
- num_retry_uploads: Number of retries for uploading the image in case of failure.
- batch_name: Upload the image to a specific batch.
- split: Upload the image to a specific split.
- tag: Store metadata as a tag on the image.
- sequence_number: [Optional] If you want to keep the order of your images in the dataset, pass sequence_number and sequence_size..
- sequence_size: [Optional] The total number of images in the sequence. Defaults to 100,000 if not set.
"""

project.upload(
    image_path="UPLOAD_IMAGE.jpg",
    batch_name="YOUR_BATCH_NAME",
    split="train",
    num_retry_uploads=3,
    tag_names=["YOUR_TAG_NAME"],
    sequence_number=99,
    sequence_size=100
)

Upload to a New Project

To upload a new project, add the following code before your model upload:

Kotlin

Uploading with base64 encoded image:

Adding an Image Hosted Elsewhere via URL:

Android (Java)

Uploading with base64 encoded image:

Adding an Image Hosted Elsewhere via URL:

View Uploaded Images in Roboflow

Images uploaded via the API can be found in the Annotate tab, under the unassigned column and marked as uploaded via API.

If you specify a batch upload parameter, your image will still be found in the Annotate tab but instead of going to the uploaded via API batch it will be found in the batch you specified.

Was this helpful?