Roboflow makes managing, preprocessing, augmenting, and versioning datasets for computer vision seamless.

Overview

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
source venv/bin/activate 
pip3 install -r requirements.txt

Quickstart

import roboflow

# Instantiate Roboflow object with your API key
rf = 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')
Comments
  • full refactor of pip package

    full refactor of pip package

    *this is an initial PR, let me know of any changes that need to be made.

    • modified structure of package to be initialized with Roboflow() object
    • added version objects to detect versioning
    • added retrieval for workspaces
    • modified all routes to reflect no workspace prefix in front of project name
    • changed tests to reflect changes
    • changed Project() object to have list of Version() objects
    opened by Palashio 5
  • Web Page not responsive

    Web Page not responsive

    I am trying to upload annotated dataset on roboflow but it takes a lot of time and becomes unresponsive at the end and all the files are being lost and i have to upload them again from the start. I have tried several times but i am unable to upload the data.

    opened by rexayyy 3
  • Dependency conflict - cannot pip install

    Dependency conflict - cannot pip install

    On Colab:

    !pip install -q roboflow
    
    .
    .
    .
    ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
    google-colab 1.0.0 requires requests~=2.23.0, but you have requests 2.27.1 which is incompatible.
    datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible.
    albumentations 0.1.12 requires imgaug<0.2.7,>=0.2.5, but you have imgaug 0.2.9 which is incompatible.
    
    
    opened by robmarkcole 3
  • `model.predict()` doesn't work on jpeg images

    `model.predict()` doesn't work on jpeg images

    The model.predict() function returns an error when an image with the jpeg extension is used.

    Traceback (most recent call last):
      File "/Users/james/src/python/roboflow-python/app.py", line 17, in <module>
        prediction = model.predict("photo.jpeg")
      File "/Users/james/src/python/roboflow-python/roboflow/models/object_detection.py", line 177, in predict
        _, buffer = cv2.imencode(os.path.splitext(image_path)[-1], image_path)
    cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'imencode'
    > Overload resolution failed:
    >  - img is not a numpy array, neither a scalar
    >  - Expected Ptr<cv::UMat> for argument 'img'
    

    When a jpg image is used, there is no error and inference runs as expected.

    This was produced using the latest version of the roboflow library on macOS.

    bug 
    opened by capjamesg 2
  • Added CI for pypi - develop branch

    Added CI for pypi - develop branch

    Description

    This PR adds a GitHub action to automatically push a new release on pypi when master is pushed.

    Moreover, this PR adds a new branch develop that must be used to push new changes before cluster them into a big PR to main.

    Let's discuss this new way to collaborate on this project

    opened by FrancescoSaverioZuppichini 2
  • added edge case handling for conditional object

    added edge case handling for conditional object

    Description

    Users were previously required to use all conditions for active learning so added edge case handling to the conditionals object in case users don't specify all possible key words.

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] This change requires a documentation update

    How has this change been tested, please provide a testcase or example of how you tested the change?

    Ran a series of unit tests with the below code snippet making sure all variations were supported including no config object, one field, all fields, some fields, value == None, etc.

    from roboflow import Roboflow
    
    rf = Roboflow(api_key="BLlkFnwfSaRFUXBfU0tJ")
    
    upload_conditions_config = {
        "target_classes": ['helmet'],
        "confidence_interval": [30,90]
    }
    
    rf.workspace().active_learning("./test_cases", ".png", ["hard-hat-universe-0dy7t", 3], "merge_tester", upload_conditions_config)
    

    Docs

    • [x] Docs updated? What were the changes: Added a note in the active learning section that you don't have to use all fields.
    opened by ogjaylowe 2
  • kiwisolver support for Python 3.10.x and other versions relaxed.

    kiwisolver support for Python 3.10.x and other versions relaxed.

    Description

    I've noticed that on certain versions of python in my case 3.10.7 kiwisolver build was failing as it required C++ 14.0 or greater build tools, that is unacceptable as this should be a simple install. So I've relaxed the kiwisolver dependencies a bit.

    List any dependencies that are required for this change. kiwisolver>=1.3.1 (instead of kiwisolver==1.3.1)

    Type of change

    Please delete options that are not relevant.

    • [ x ] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] This change requires a documentation update

    How has this change been tested, please provide a testcase or example of how you tested the change?

    Relaxed kiwisolver would help ease install for Windows users. YOUR_ANSWER

    Any specific deployment considerations

    None

    For example, documentation changes, usability, usage/costs, secrets, etc.

    Docs

    • [ ] Docs updated? What were the changes:
    opened by OttomanZ 2
  • Enter: Instance segmentation

    Enter: Instance segmentation

    Description

    This adds Instance Segmentation functionality to the python pip package. I also did a small bit of refactoring but tried to avoid going wild.

    Type of change

    • [x] New feature (non-breaking change which adds functionality)

    How has this change been tested, please provide a testcase or example of how you tested the change?

    A couple unit tests have been added. I also tested the new functionality manually via:

    import os
    import roboflow
    
    ROBOFLOW_API_KEY = os.environ.get("ROBOFLOW_API_KEY")
    WORKSPACE_NAME = os.environ.get("WORKSPACE_NAME", "")
    PROJECT_NAME = os.environ.get("PROJECT_NAME")
    PROJECT_VERSION = os.environ.get("PROJECT_VERSION", "1")
    
    LOCAL_IMAGE = "<local image path>"
    HOSTED_IMAGE = "<remote image url>"
    
    # Instantiate Roboflow object with your API key
    rf = roboflow.Roboflow(api_key=ROBOFLOW_API_KEY)
    
    # List all projects for your workspace
    workspace = rf.workspace()
    print(f'workspace: {workspace}')
    
    # Load a certain project, workspace url is optional
    project = rf.project(PROJECT_NAME)
    print(f'project: {project}')
    
    # List all versions of a specific project
    project.versions()
    print(f'versions: {project.versions()}')
    
    print(f'images: {project.images}')
    
    # Upload image to dataset
    # project.upload(LOCAL_IMAGE)
    
    # Retrieve the model of a specific project
    model = project.version(PROJECT_VERSION).model
    print(f'model: {model}')
    
    # # predict on a local image
    # prediction = model.predict(LOCAL_IMAGE)
    # print(prediction)
    
    # Predict on a hosted image
    prediction = model.predict(HOSTED_IMAGE) # , hosted=True)
    print(prediction)
    
    # Plot the prediction
    prediction.plot()
    print(prediction.plot())
    
    # Convert predictions to JSON
    prediction.json()
    print(prediction.json())
    
    # Save the prediction as an image
    prediction.save(output_path='predictions.jpg')
    

    Any specific deployment considerations

    Once this is merged, we will need to update the docs that are displayed on instance segmentation projects.

    eg:

    Infer on Local and Hosted Images

    To install dependencies, pip install roboflow

    from roboflow import Roboflow
    
    rf = Roboflow(api_key="API_KEY")
    project = rf.workspace().project("MODEL_ENDPOINT")
    model = project.version(VERSION).model
    
    # infer on a local image
    print(model.predict("your_image.jpg").json())
    
    # infer on an image hosted elsewhere
    print(model.predict("https://example.com/your_image.jpg").json())
    
    # change the confidence for your prediction
    print(model.predict("your_image.jpg", confidence=60).json())
    
    # visualize your prediction
    model.predict("your_image.jpg").save("prediction.jpg")
    

    Docs

    • [ ] Docs updated? What were the changes:
    opened by broox 2
  • Fix issue with github action not working from forked repo pull requests

    Fix issue with github action not working from forked repo pull requests

    Description

    I noticed that the github workflows were not working in https://github.com/roboflow-ai/roboflow-python/pull/51 There seems to be an issue referencing the branch since it exists on the forked repo rather than the main repo.

    Run actions/checkout@v3
    Syncing repository: roboflow-ai/roboflow-python
    Getting Git version info
    Temporarily overriding HOME='/home/runner/work/_temp/c9897c44-666d-4cac-b37c-b1cf27451ab3' before making global git config changes
    Adding repository directory to the temporary git global config as a safe directory
    /usr/bin/git config --global --add safe.directory /home/runner/work/roboflow-python/roboflow-python
    Deleting the contents of '/home/runner/work/roboflow-python/roboflow-python'
    Initializing the repository
    Disabling automatic garbage collection
    Setting up auth
    Fetching the repository
      /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/accept-JPG*:refs/remotes/origin/accept-JPG* +refs/tags/accept-JPG*:refs/tags/accept-JPG*
      The process '/usr/bin/git' failed with exit code 1
      Waiting [13](https://github.com/roboflow-ai/roboflow-python/actions/runs/3063095031/jobs/4944798073#step:2:14) seconds before trying again
      /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/accept-JPG*:refs/remotes/origin/accept-JPG* +refs/tags/accept-JPG*:refs/tags/accept-JPG*
      The process '/usr/bin/git' failed with exit code 1
      Waiting 17 seconds before trying again
      /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/accept-JPG*:refs/remotes/origin/accept-JPG* +refs/tags/accept-JPG*:refs/tags/accept-JPG*
      Error: The operation was canceled.
    

    After making the change to remove the with: block from the Checkout step, the github action seemed to run properly, however tests failed with the following error:

    Run python -m unittest
    upload and label your dataset, and get an API KEY here: https://app.roboflow.com/?model=undefined&ref=undefined
    E
    
    ======================================================================
    loading Roboflow workspace...
    ERROR: tests.test (unittest.loader._FailedTest)
    ----------------------------------------------------------------------
    ImportError: Failed to import test module: tests.test
    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.9.[13](https://github.com/roboflow-ai/roboflow-python/actions/runs/3063184200/jobs/4944979507#step:6:14)/x64/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
        module = self._get_module_from_name(name)
      File "/opt/hostedtoolcache/Python/3.9.13/x64/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
        __import__(name)
      File "/home/runner/work/roboflow-python/roboflow-python/tests/test.py", line 35, in <module>
        class TestQueries(unittest.TestCase):
      File "/home/runner/work/roboflow-python/roboflow-python/tests/test.py", line 38, in TestQueries
        workspace = rf.workspace()
      File "/home/runner/work/roboflow-python/roboflow-python/roboflow/__init__.py", line 88, in workspace
        the_workspace = self.current_workspace
    AttributeError: 'Roboflow' object has no attribute 'current_workspace'
    
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
    
    FAILED (errors=1)
    Error: Process completed with exit code 1.
    

    This seems to be due to to the main repository's secrets not being accessible by my forked code. Changing the pull_request workflow to a pull_request_target workflow, may fix this... but it also may introduce vulnerabilities. A better fix might be to mock API requests rather than make real ones.

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)

    How has this change been tested, please provide a testcase or example of how you tested the change?

    we'll see what github actions say 😄

    Any specific deployment considerations

    No

    opened by broox 2
  • Refactor tests and fix inability to upload valid image formats with capitalized extensions

    Refactor tests and fix inability to upload valid image formats with capitalized extensions

    Description

    While testing image uploading, I discovered that the logic to check whether an image is in an acceptable format was rather naive and buggy. This should make it a bit more robust.

    I also added some tests to prove the bug and its fix. While doing that, I refactored the test suite a bit to allow for more extensibility... and then I went down a bit of a rabbit hole once i realized that secrets couldn't be read and used from a forked PR. I'm happy to break test refactoring out into its own PR if that makes more sense.

    Fixes #50

    Type of change

    Please delete options that are not relevant.

    • [x] Bug fix (non-breaking change which fixes an issue)

    How has this change been tested, please provide a testcase or example of how you tested the change?

    I wrote and ran tests to prove the bug and then prove the fix. I also manually tested that I could upload an image with the capitalized JPG extension and saw it in the Roboflow web UI.

    Any specific deployment considerations

    Nope

    opened by broox 2
  • ERR_NGROK_6022 Before you can serve HTML content, you must sign up for a free ngrok account and install your authtoken

    ERR_NGROK_6022 Before you can serve HTML content, you must sign up for a free ngrok account and install your authtoken

    I have followed the ROBOFLOW-tensorflow-object-detection-faster-rcnn notebook.At line get tensorboard link i get this error.Anyone can say what the problem ?

    opened by Faisal00001 2
  • Fix for json_response[

    Fix for json_response["image"] in prediction.py

    Description

    There was an issue because we changed our data structure recently. The resulted in json_response["image"] not existing.

    Used PIL to get image dimensions and reconstructed img_dims.

    No dependency changes

    Type of change

    Please delete options that are not relevant.

    • [X] Bug fix (non-breaking change which fixes an issue)
    • [ ] New feature (non-breaking change which adds functionality)
    • [ ] This change requires a documentation update

    How has this change been tested, please provide a testcase or example of how you tested the change?

    Tested on two TRT scripts and with three different models. Have yet to test it on an edge device, but this fix should not be device specific.

    Any specific deployment considerations

    Reading image for image dimensions takes time, if there is a more efficient way to get img_dims or if we are already pulling dims somewhere else in the script. We should pass the variable instead of creating another variable.

    bug 
    opened by Tyler-Odenthal 0
  • Wrong number of classes in data.yaml

    Wrong number of classes in data.yaml

    Description

    After labelling all the images in the dataset, when generating a new dataset version and downloading it, the data.yaml created additional non-existing classes.

    Steps to reproduce

    1. Label your data
    2. Create a new dataset version
    3. Check the Modify Classses pre-processing step to make sure you have the right classes
    4. Generate the dataset version
    5. Download the dataset
    6. Check the classes in data.yaml

    Expected result

    You should only get the classes that you labeled

    Actual result

    The roboflow creates additional non-existing classes (this also alters the class_id of the real classes)

    Note: While labeling, there were some classes that were created by mistake, but they were deleted afterwards since they were never used. This somehow was still picked up by the roboflow.

    Evidence

    You can clearly see I had 2 classes: image

    When downloading the dataset, its data.yaml config file looked like this: image

    This remapped my original class_id's of course. This was my original data.yaml:

    image

    bug 
    opened by sannicosan 3
  • CLI Auth Compatibility

    CLI Auth Compatibility

    Description

    This PR adds CLI auth compatibility

    We check for configuration from:

    1. env vars
    2. CLI config
    3. defaults

    It is compatible with the old Roboflow(api_key="") and now a new Roboflow() object

    You can test functionality with the CLI roboflow auth and then

    from roboflow import Roboflow
    
    rf = Roboflow()
    
    opened by Jacobsolawetz 1
Releases(v0.2.23)
  • v0.2.23(Dec 30, 2022)

  • v0.2.22(Dec 30, 2022)

    Added:

    • version generation from project
    • automatic exporting of formants that are not exported
    • training from version
    • training from projects
    • active learning support for RSTP streams
    Source code(tar.gz)
    Source code(zip)
  • v0.2.21(Dec 2, 2022)

    Making releases sync with pypi, please check commits for all the updates from the previous on GitHub.

    The full release list between the previous on GitHub and this one is pypi

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Sep 15, 2021)

    First official release of roboflow pip package! More information can be found on our announcement blog post.

    • access information about your projects, workspaces, and versions through python.
    • perform inference on local, or hosted images
    • analyze, and save inference
    Source code(tar.gz)
    Source code(zip)
This is a Computer vision package that makes its easy to run Image processing and AI functions. At the core it uses OpenCV and Mediapipe libraries.

CVZone This is a Computer vision package that makes its easy to run Image processing and AI functions. At the core it uses OpenCV and Mediapipe librar

CVZone 648 Dec 30, 2022
A dataset handling library for computer vision datasets in LOST-fromat

A dataset handling library for computer vision datasets in LOST-fromat

null 8 Dec 15, 2022
Augmenting Anchors by the Detector Itself

Augmenting Anchors by the Detector Itself Introduction It is difficult to determine the scale and aspect ratio of anchors for anchor-based object dete

null 4 Nov 6, 2022
An organized collection of tutorials and projects created for aspriring computer vision students.

A repository created with the purpose of teaching students in BME lab 308A- Hanoi University of Science and Technology

Givralnguyen 5 Nov 24, 2021
Using computer vision method to recognize and calcutate the features of the architecture.

building-feature-recognition In this repository, we accomplished building feature recognition using traditional/dl-assisted computer vision method. Th

null 4 Aug 11, 2022
computer vision, image processing and machine learning on the web browser or node.

Image processing and Machine learning labs   computer vision, image processing and machine learning on the web browser or node note Fast Fourier Trans

ryohei tanaka 487 Nov 11, 2022
Omdena-abuja-anpd - Automatic Number Plate Detection for the security of lives and properties using Computer Vision.

Omdena-abuja-anpd - Automatic Number Plate Detection for the security of lives and properties using Computer Vision.

Abdulazeez Jimoh 1 Jan 1, 2022
Computer vision applications project (Flask and OpenCV)

Computer Vision Applications Project This project is at it's initial phase. This is all about the implementation of different computer vision techniqu

Suryam Thapa 1 Jan 26, 2022
Open Source Differentiable Computer Vision Library for PyTorch

Kornia is a differentiable computer vision library for PyTorch. It consists of a set of routines and differentiable modules to solve generic computer

kornia 7.6k Jan 4, 2023
Open Source Computer Vision Library

OpenCV: Open Source Computer Vision Library Resources Homepage: https://opencv.org Courses: https://opencv.org/courses Docs: https://docs.opencv.org/m

OpenCV 65.7k Jan 3, 2023
"Very simple but works well" Computer Vision based ID verification solution provided by LibraX.

ID Verification by LibraX.ai This is the first free Identity verification in the market. LibraX.ai is an identity verification platform for developers

LibraX.ai 46 Dec 6, 2022
Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Visual Behavior 86 Dec 28, 2022
Kornia is a open source differentiable computer vision library for PyTorch.

Open Source Differentiable Computer Vision Library

kornia 7.6k Jan 6, 2023
Multi-choice answer sheet correction system using computer vision with opencv & python.

Multi choice answer correction ?? 5 answer sheet samples with a specific solution for detecting answers and sheet correction. ?? By running the soluti

Reza Firouzi 7 Mar 7, 2022
Repository for playing the computer vision apps: People analytics on Raspberry Pi.

play-with-torch Repository for playing the computer vision apps: People analytics on Raspberry Pi. Tools Tested Hardware RasberryPi 4 Model B here, RA

eMHa 1 Sep 23, 2021
This repository summarized computer vision theories.

This repository summarized computer vision theories.

null 3 Feb 4, 2022
SRA's seminar on Introduction to Computer Vision Fundamentals

Introduction to Computer Vision This repository includes basics to : Python Numpy: A python library Git Computer Vision. The aim of this repository is

Society of Robotics and Automation 147 Dec 4, 2022
Python Computer Vision application that allows users to draw/erase on the screen using their webcam.

CV-Virtual-WhiteBoard The Virtual WhiteBoard is a project I made using the OpenCV and Mediapipe Python libraries. Using your index and middle finger y

Stephen Wang 1 Jan 7, 2022
Smart computer vision application

Smart-computer-vision-application Backend : opencv and python Library required:

null 2 Jan 31, 2022