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)
Code for the paper "Controllable Video Captioning with an Exemplar Sentence"

SMCG Code for the paper "Controllable Video Captioning with an Exemplar Sentence" Introduction We investigate a novel and challenging task, namely con

10 Dec 04, 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
Convert PDF/Image to TXT using EasyOcr - the best OCR engine available!

PDFImage2TXT - DOWNLOAD INSTALLER HERE What can you do with it? Convert scanned PDFs to TXT. Convert scanned Documents to TXT. No coding required!! In

Hans Alemão 2 Feb 22, 2022
kaldi-asr/kaldi is the official location of the Kaldi project.

Kaldi Speech Recognition Toolkit To build the toolkit: see ./INSTALL. These instructions are valid for UNIX systems including various flavors of Linux

Kaldi 12.3k Jan 05, 2023
Code release for Hu et al., Learning to Segment Every Thing. in CVPR, 2018.

Learning to Segment Every Thing This repository contains the code for the following paper: R. Hu, P. Dollár, K. He, T. Darrell, R. Girshick, Learning

Ronghang Hu 417 Oct 03, 2022
Genalog is an open source, cross-platform python package allowing generation of synthetic document images with custom degradations and text alignment capabilities.

Genalog is an open source, cross-platform python package allowing generation of synthetic document images with custom degradations and text alignment capabilities.

Microsoft 235 Dec 22, 2022
Self-supervised Equivariant Attention Mechanism for Weakly Supervised Semantic Segmentation, CVPR 2020 (Oral)

SEAM The implementation of Self-supervised Equivariant Attention Mechanism for Weakly Supervised Semantic Segmentaion. You can also download the repos

Hibercraft 459 Dec 26, 2022
Python-based tools for document analysis and OCR

ocropy OCRopus is a collection of document analysis programs, not a turn-key OCR system. In order to apply it to your documents, you may need to do so

OCRopus 3.2k Dec 31, 2022
The open source extract transaction infomation by using OCR.

Transaction OCR Mã nguồn trích xuất thông tin transaction từ file scaned pdf, ở đây tôi lựa chọn tài liệu sao kê công khai của Thuy Tien. Mã nguồn có

Nguyen Xuan Hung 18 Jun 02, 2022
Usando o Amazon Textract como OCR para Extração de Dados no DynamoDB

dio-live-textract2 Repositório de código para o live coding do dia 05/10/2021 sobre extração de dados estruturados e gravação em banco de dados a part

hugoportela 0 Jan 19, 2022
Thresholding-and-masking-using-OpenCV - Image Thresholding is used for image segmentation

Image Thresholding is used for image segmentation. From a grayscale image, thresholding can be used to create binary images. In thresholding we pick a threshold T.

Grace Ugochi Nneji 3 Feb 15, 2022
Official code for "Bridging Video-text Retrieval with Multiple Choice Questions", CVPR 2022 (Oral).

Bridging Video-text Retrieval with Multiple Choice Questions, CVPR 2022 (Oral) Paper | Project Page | Pre-trained Model | CLIP-Initialized Pre-trained

Applied Research Center (ARC), Tencent PCG 99 Jan 06, 2023
document image degradation

ocrodeg The ocrodeg package is a small Python library implementing document image degradation for data augmentation for handwriting recognition and OC

NVIDIA Research Projects 134 Nov 18, 2022
基于openpose和图像分类的手语识别项目

手语识别 0、使用到的模型 (1). openpose,作者:CMU-Perceptual-Computing-Lab https://github.com/CMU-Perceptual-Computing-Lab/openpose (2). 图像分类classification,作者:Bubbl

20 Dec 15, 2022
Official implementation of "An Image is Worth 16x16 Words, What is a Video Worth?" (2021 paper)

An Image is Worth 16x16 Words, What is a Video Worth? paper Official PyTorch Implementation Gilad Sharir, Asaf Noy, Lihi Zelnik-Manor DAMO Academy, Al

213 Nov 12, 2022
list all open dataset about ocr.

ocr-open-dataset list all open dataset about ocr. printed dataset year Born-Digital Images (Web and Email) 2011-2015 COCO-Text 2017 Text Extraction fr

hongbomin 95 Nov 24, 2022
[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
Repositório para registro de estudo da biblioteca opencv (Python)

OpenCV (Python) Objetivo do Repositório: Registrar avanços no estudo da biblioteca opencv. O repositório estará aberto a qualquer pessoa e há tambem u

1 Jun 14, 2022
[BMVC'21] Official PyTorch Implementation of Grounded Situation Recognition with Transformers

Grounded Situation Recognition with Transformers Paper | Model Checkpoint This is the official PyTorch implementation of Grounded Situation Recognitio

Junhyeong Cho 18 Jul 19, 2022
Visual Attention based OCR

Attention-OCR Authours: Qi Guo and Yuntian Deng Visual Attention based OCR. The model first runs a sliding CNN on the image (images are resized to hei

Yuntian Deng 1.1k Jan 02, 2023