Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The official Roboflow Python package. Manage your datasets, models, and deployments. Roboflow has everything you need to build a computer vision application.

License

Notifications You must be signed in to change notification settings

softwareengineer-imerjr/roboflow-python

 
 

Repository files navigation

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
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 [email protected]:roboflow-ai/roboflow-python.git && cd roboflow-python

# Copy the environment variables template
# Be sure to update the values with your account's information
cp .env-example .env

# Build and run a new docker container image
docker run -it -v $(pwd):/roboflow --name roboflow python:3.8.14-slim /bin/bash

# Install Dependencies
cd roboflow/ && pip install -e ".[dev]"

# Run tests
python -m unittest

Running the Docker container after initial build:

docker start roboflow
docker exec -it roboflow /bin/bash
cd roboflow/ && python -m unittest

Using Virtualenv

# Clone this repo
git clone [email protected]: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

You need to have the following env variables defined. If using docker along with the .env file, these will be automatically defined.

ROBOFLOW_API_KEY="<YOUR_ROBOFLOW_PRIVATE_API_KEY>"
PROJECT_NAME="<YOUR_PROJECT_NAME>"
PROJECT_VERSION="1"

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

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.

About

The official Roboflow Python package. Manage your datasets, models, and deployments. Roboflow has everything you need to build a computer vision application.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 98.7%
  • Shell 1.2%
  • Makefile 0.1%