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)
A curated list of awesome synthetic data for text location and recognition

awesome-SynthText A curated list of awesome synthetic data for text location and recognition and OCR datasets. Text location SynthText SynthText_Chine

Tianzhong 283 Jan 05, 2023
Text Detection from images using OpenCV

EAST Detector for Text Detection OpenCV’s EAST(Efficient and Accurate Scene Text Detection ) text detector is a deep learning model, based on a novel

Abhishek Singh 88 Oct 20, 2022
A tool to enhance your old/damaged pictures built using python & opencv.

Breathe Life into your Old Pictures Table of Contents About The Project Getting Started Prerequisites Usage Contact Acknowledgments About The Project

Shah Anwaar Khalid 5 Dec 16, 2021
Convert Text-to Handwriting Using Python

Convert Text-to Handwriting Using Python Description In this project we'll use python library that's "pywhatkit" for converting text to handwriting. t

8 Nov 19, 2022
Awesome Spectral Indices in Python.

Awesome Spectral Indices in Python: Numpy | Pandas | GeoPandas | Xarray | Earth Engine | Planetary Computer | Dask GitHub: https://github.com/davemlz/

David Montero Loaiza 98 Jan 02, 2023
Image processing in Python

scikit-image: Image processing in Python Website (including documentation): https://scikit-image.org/ Mailing list: https://mail.python.org/mailman3/l

Image Processing Toolbox for SciPy 5.2k Dec 30, 2022
make a better chinese character recognition OCR than tesseract

deep ocr See README_en.md for English installation documentation. 只在ubuntu下面测试通过,需要virtualenv安装,安装路径可自行调整: git clone https://github.com/JinpengLI/deep

Jinpeng 1.5k Dec 28, 2022
This repo contains several opencv projects done while learning opencv in python.

opencv-projects-python This repo contains both several opencv projects done while learning opencv by python and opencv learning resources [Basic conce

Fatin Shadab 2 Nov 03, 2022
MORAN: A Multi-Object Rectified Attention Network for Scene Text Recognition

MORAN: A Multi-Object Rectified Attention Network for Scene Text Recognition Python 2.7 Python 3.6 MORAN is a network with rectification mechanism for

Canjie Luo 595 Dec 27, 2022
Recognizing the text contents from a scanned visiting card

Recognizing the text contents from a scanned visiting card. The application which is used to recognize the text from scanned images,printeddocuments,r

Faizan Habib 1 Jan 28, 2022
Multi-Oriented Scene Text Detection via Corner Localization and Region Segmentation

This is the official implementation of "Multi-Oriented Scene Text Detection via Corner Localization and Region Segmentation". For more details, please

Pengyuan Lyu 309 Dec 06, 2022
How to detect objects in real time by using Jupyter Notebook and Neural Networks , by using Yolo3

Real Time Object Recognition From your Screen Desktop . In this post, I will explain how to build a simply program to detect objects from you desktop

Ruslan Magana Vsevolodovna 2 Sep 28, 2022
Handwriting Recognition System based on a deep Convolutional Recurrent Neural Network architecture

Handwriting Recognition System This repository is the Tensorflow implementation of the Handwriting Recognition System described in Handwriting Recogni

Edgard Chammas 346 Jan 07, 2023
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
TedEval: A Fair Evaluation Metric for Scene Text Detectors

TedEval: A Fair Evaluation Metric for Scene Text Detectors Official Python 3 implementation of TedEval | paper | slides Chae Young Lee, Youngmin Baek,

Clova AI Research 167 Nov 20, 2022
Repository collecting all the submodules for the new PyTorch-based OCR System.

OCRopus3 is being replaced by OCRopus4, which is a rewrite using PyTorch 1.7; release should be soonish. Please check github.com/tmbdev/ocropus for up

NVIDIA Research Projects 138 Dec 09, 2022
Morphological edge detection or object's boundary detection using erosion and dialation in OpenCV python

Morphologycal-edge-detection-using-erosion-and-dialation the task is to detect object boundary using erosion or dialation . Here, use the kernel or st

Tamzid hasan 3 Nov 25, 2022
Detecting Text in Natural Image with Connectionist Text Proposal Network (ECCV'16)

Detecting Text in Natural Image with Connectionist Text Proposal Network The codes are used for implementing CTPN for scene text detection, described

Tian Zhi 1.3k Dec 22, 2022
Tensorflow-based CNN+LSTM trained with CTC-loss for OCR

Overview This collection demonstrates how to construct and train a deep, bidirectional stacked LSTM using CNN features as input with CTC loss to perfo

Jerod Weinman 489 Dec 21, 2022
Generic framework for historical document processing

dhSegment dhSegment is a tool for Historical Document Processing. Its generic approach allows to segment regions and extract content from different ty

Digital Humanities Laboratory 343 Dec 24, 2022