Skip to main content

Roboflow Python Library


roboflow logo

Website • Docs • Blog • Twitter • Linkedin • Universe

Roboflow makes managing, preprocessing, augmenting, and versioning datasets for computer vision seamless. This is the official Roboflow python package that interfaces with the Roboflow API. Key features of Roboflow:

Installation:

To install this package, please use Python 3.6 or higher. We provide three different ways to install the Roboflow package to use within your own projects.

Install from PyPi (Recommended):

pip install roboflow

Install from Source:

git clone https://github.com/roboflow-ai/roboflow-python.git
cd roboflow-python
python3 -m venv env
source env/bin/activate 
pip3 install -r requirements.txt

Quickstart

import roboflow

# Instantiate Roboflow object with your API key
rf = roboflow.Roboflow(api_key=YOUR_API_KEY_HERE)

# List all projects for your workspace
workspace = rf.workspace()

# Load a certain project, workspace url is optional
project = rf.project("PROJECT_ID")

# List all versions of a specific project
project.versions()

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

# Retrieve the model of a specific project
model = project.version("1").model

# predict on a local image
prediction = model.predict("YOUR_IMAGE.jpg")

# Predict on a hosted image
prediction = model.predict("YOUR_IMAGE.jpg", hosted=True)

# Plot the prediction
prediction.plot()

# Convert predictions to JSON
prediction.json()

# Save the prediction as an image
prediction.save(output_path='predictions.jpg')

Using this package for a specifc project

If you have a specific project from your workspace you'd like to run in a notebook follow along on this tutorial Downloading Datasets from Roboflow for Training (Python)

Selecting the format you'd like your project to be exported as while choosing the show download code option will display code snippets you can use in either Jupyter or your terminal. These code snippets will include your api_key, project, and workspace names.

Alt Text

Developing locally

Using Docker

To set the Docker container up for the first time:

# Clone this repo
git clone git@github.com:roboflow-ai/roboflow-python.git && cd roboflow-python

# Copy the environment variables template
# Be sure to update the values with your account's information

# Build our development image
docker build -t roboflow-python -f Dockerfile.dev .

# Run container and map current folder in it
docker run --rm -it \
  -v $(pwd)/:/workspace/ \
  --env-file .env \
  roboflow-python 

# Run tests
python -m unittest

Change Python version

You can pass the build arg PYTHON_VERSION to dynamically change python version at build time

docker build  -t roboflow-python --build-arg PYTHON_VERSION=3.9 -f Dockerfile.dev .

Will use python:3.9-slim

Note If you are using VSCode we reccomend to read the "Developing inside a Container" tutorial.

Using Virtualenv

# Clone this repo
git clone git@github.com:roboflow-ai/roboflow-python.git && cd roboflow-python

# create virtual env
virtualenv local_dev

# activate virtual env
source local_dev/bin/activate

# install dependencies
pip3 install -e ".[dev]"

Testing

Make sure you have your virtualenv spun up before running tests. Execute the unittest command at the /root level directory.

Run tests:

python -m unittest

Contributing

  1. Increment the pip package minor version number in setup.py
  2. Manually add any new dependencies to requirements.txt with a version such as chardet==4.0.0 and list of dependencies in setup.py (Be careful not to overwrite any packages that might screw up backwards dependencies for object detection, etc.)

Code Quality

When creating new functions, please follow the Google style Python docstrings. See example below:

def example_function(param1: int, param2: str) -> bool:
    """Example function that does something.

    Args:
        param1: The first parameter.
        param2: The second parameter.

    Returns:
        The return value. True for success, False otherwise.

    """

We provide a Makefile to format and ensure code quality. Be sure to run them before creating a PR.

# format your code with `black` and `isort` run
make style
# check code with flake8
make check_code_quality

Note These tests will be run automatically when you commit thanks to git hooks.

Release files for roboflow 0.2.18

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for roboflow 0.2.18
File Size Uploaded
roboflow-0.2.18.tar.gz 33.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for roboflow 0.2.18
File Interpreter ABI Platform
roboflow-0.2.18-py3-none-any.whl Python 3 none any Details

Total release size: 74.9 kB

Release files / roboflow-0.2.18.tar.gz

Download URL roboflow-0.2.18.tar.gz
Size 33.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7a00f6d78649bf35ac9f10b9f50cf13d5ae319cb9a23f60513ed78875eff93c5
BLAKE2b-256 checksum
How to use checksums
838379ed7d8e50070e0c1b723cd5cfd07f791e56ddff32d8959cce15833719f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release files / roboflow-0.2.18-py3-none-any.whl

Download URL roboflow-0.2.18-py3-none-any.whl
Size 41.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ce2b1705e348d50ce429c624297844874c864daf57d8caafb3e4e4f537aa805
BLAKE2b-256 checksum
How to use checksums
cb9b79c9b62fd0227c089439a0d8124fe6e91a03c2deecfc4e0cbd211705bc1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

1.5.1

2 release files

1.5.0

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.2.15

2 release files

1.2.14

2 release files

1.2.13

2 release files

1.2.12

2 release files

1.2.11

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.67

2 release files

1.1.65

2 release files

1.1.64

2 release files

1.1.63

2 release files

1.1.62

2 release files

1.1.61

2 release files

1.1.58

2 release files

1.1.57

2 release files

1.1.56

2 release files

1.1.55

2 release files

1.1.54

2 release files

1.1.53

2 release files

1.1.51

2 release files

1.1.50

2 release files

1.1.48

2 release files

1.1.45

2 release files

1.1.44

2 release files

1.1.43

2 release files

1.1.42

2 release files

1.1.41

2 release files

1.1.40

2 release files

1.1.39

2 release files

1.1.38

2 release files

1.1.37

2 release files

1.1.36

2 release files

1.1.35

2 release files

1.1.33

2 release files

1.1.32

2 release files

1.1.30

2 release files

1.1.29

2 release files

1.1.28

2 release files

1.1.27

2 release files

1.1.26

2 release files

1.1.25

2 release files

1.1.24

2 release files

1.1.21

2 release files

1.1.20

2 release files

1.1.18

2 release files

1.1.17

2 release files

1.1.14

2 release files

1.1.13

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.34

2 release files

0.2.32

2 release files

0.2.31

2 release files

0.2.30

2 release files

0.2.29

2 release files

0.2.28

2 release files

0.2.27

2 release files

0.2.26

2 release files

0.2.25

2 release files

0.2.24

2 release files

0.2.23

2 release files

0.2.22

2 release files

0.2.20

2 release files

0.2.19

2 release files

This release

0.2.18 This release

2 release files

0.2.17

2 release files

0.2.16

2 release files

0.2.15

2 release files

0.2.12

2 release files

0.2.11

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.2

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page