Skip to main content

python client for the Roboflow application

Project description

Roboflow Python Library


roboflow logo

WebsiteDocsBlogTwitterLinkedinUniverse

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 specific project

If you have a specific project from your workspace you'd like to run in a notebook, follow along with 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 recommend you 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 code with `black` and `isort`
make style

# check code with flake8
make check_code_quality

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

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

roboflow-0.2.27.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

roboflow-0.2.27-py3-none-any.whl (46.8 kB view details)

Uploaded Python 3

File details

Details for the file roboflow-0.2.27.tar.gz.

File metadata

  • Download URL: roboflow-0.2.27.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for roboflow-0.2.27.tar.gz
Algorithm Hash digest
SHA256 0471d6d655bc4eea2d3c5ea6f6cdfb680e9c3919e2744fb6f3ebe4ba6c848a25
MD5 7a59e929cb04736c114c10c13c19689b
BLAKE2b-256 c575aa9e80a589078873cfe7c2e6e3d6bd6749da499620af2f593cb265835085

See more details on using hashes here.

File details

Details for the file roboflow-0.2.27-py3-none-any.whl.

File metadata

  • Download URL: roboflow-0.2.27-py3-none-any.whl
  • Upload date:
  • Size: 46.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for roboflow-0.2.27-py3-none-any.whl
Algorithm Hash digest
SHA256 f375ae6c199552ad7457b96854d5dca020851eef75be247a741d778641013ca6
MD5 f3d1d7f903bfa4090ca8aa2d0abdb2d9
BLAKE2b-256 c4843210a7a3d49f1ce8f3b467b590d37122b35c17ec4dc58ed1c3fb9e760fb2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page