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/[email protected]
    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)
[EMNLP 2021] Improving and Simplifying Pattern Exploiting Training

ADAPET This repository contains the official code for the paper: "Improving and Simplifying Pattern Exploiting Training". The model improves and simpl

Rakesh R Menon 138 Dec 26, 2022
color detection using python

colordetection color detection using python In this color detection Python project, we are going to build an application through which you can automat

Ruchith Kumar 1 Nov 04, 2021
(CVPR 2021) ST3D: Self-training for Unsupervised Domain Adaptation on 3D Object Detection

ST3D Code release for the paper ST3D: Self-training for Unsupervised Domain Adaptation on 3D Object Detection, CVPR 2021 Authors: Jihan Yang*, Shaoshu

CVMI Lab 224 Dec 28, 2022
BNF Globalization Code (CVPR 2016)

Boundary Neural Fields Globalization This is the code for Boundary Neural Fields globalization method. The technical report of the method can be found

25 Apr 15, 2022
Python library to extract tabular data from images and scanned PDFs

Overview ExtractTable - API to extract tabular data from images and scanned PDFs The motivation is to make it easy for developers to extract tabular d

Org. Account 165 Dec 31, 2022
This repository provides train&test code, dataset, det.&rec. annotation, evaluation script, annotation tool, and ranking.

SCUT-CTW1500 Datasets We have updated annotations for both train and test set. Train: 1000 images [images][annos] Additional point annotation for each

Yuliang Liu 600 Dec 18, 2022
Simple app for visual editing of Page XML files

Name nw-page-editor - Simple app for visual editing of Page XML files. Version: 2021.02.22 Description nw-page-editor is an application for viewing/ed

Mauricio Villegas 27 Jun 20, 2022
WACV 2022 Paper - Is An Image Worth Five Sentences? A New Look into Semantics for Image-Text Matching

Is An Image Worth Five Sentences? A New Look into Semantics for Image-Text Matching Code based on our WACV 2022 Accepted Paper: https://arxiv.org/pdf/

Andres 13 Dec 17, 2022
nofacedb/faceprocessor is a face recognition engine for NoFaceDB program complex.

faceprocessor nofacedb/faceprocessor is a face recognition engine for NoFaceDB program complex. Tech faceprocessor uses a number of open source projec

NoFaceDB 3 Sep 06, 2021
code for our ICCV 2021 paper "DeepCAD: A Deep Generative Network for Computer-Aided Design Models"

DeepCAD This repository provides source code for our paper: DeepCAD: A Deep Generative Network for Computer-Aided Design Models Rundi Wu, Chang Xiao,

Rundi Wu 85 Dec 31, 2022
Connect Aseprite to Blender for painting pixelart textures in real time

Pribambase Pribambase is a small tool that connects Aseprite and Blender, to allow painting with instant viewport feedback and all functionality of ex

117 Jan 03, 2023
Super Mario Game With Python

Super_Mario Hello all this is a simple python program which tries to use our body as a controller for the super mario game Here I have used media pipe

Adarsh Badagala 219 Nov 25, 2022
Image processing is one of the most common term in computer vision

Image processing is one of the most common term in computer vision. Computer vision is the process by which computers can understand images and videos, and how they are stored, manipulated, and retri

Happy N. Monday 3 Feb 15, 2022
Sign Language Recognition service utilizing a deep learning model with Long Short-Term Memory to perform sign language recognition.

Sign Language Recognition Service This is a Sign Language Recognition service utilizing a deep learning model with Long Short-Term Memory to perform s

Martin Lønne 1 Jan 08, 2022
A fastai/PyTorch package for unpaired image-to-image translation.

Unpaired image-to-image translation A fastai/PyTorch package for unpaired image-to-image translation currently with CycleGAN implementation. This is a

Tanishq Abraham 120 Dec 02, 2022
A dataset handling library for computer vision datasets in LOST-fromat

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

8 Dec 15, 2022
Code for the AAAI 2018 publication "SEE: Towards Semi-Supervised End-to-End Scene Text Recognition"

SEE: Towards Semi-Supervised End-to-End Scene Text Recognition Code for the AAAI 2018 publication "SEE: Towards Semi-Supervised End-to-End Scene Text

Christian Bartz 572 Jan 05, 2023
Handwritten Text Recognition (HTR) system implemented with TensorFlow.

Handwritten Text Recognition with TensorFlow Update 2021: more robust model, faster dataloader, word beam search decoder also available for Windows Up

Harald Scheidl 1.5k Jan 07, 2023
基于图像识别的开源RPA工具,理论上可以支持所有windows软件和网页的自动化

SimpleRPA 基于图像识别的开源RPA工具,理论上可以支持所有windows软件和网页的自动化 简介 SimpleRPA是一款python语言编写的开源RPA工具(桌面自动控制工具),用户可以通过配置yaml格式的文件,来实现桌面软件的自动化控制,简化繁杂重复的工作,比如运营人员给用户发消息,

Song Hui 7 Jun 26, 2022
Face_mosaic - Mosaic blur processing is applied to multiple faces appearing in the video

動機 face_recognitionを使用して得られる顔座標は長方形であり、この座標をそのまま用いてぼかし処理を行った場合得られる画像は醜い。 それに対してモ

Yoshitsugu Kesamaru 6 Feb 03, 2022