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)
原神风花节自动弹琴辅助

GenshinAutoPlayBalladsofBreeze 原神风花节自动弹琴辅助(已适配1920*1080分辨率) 本程序基于opencv图像识别技术,不存在任何封号。 因为正确率取决于你的cpu性能,10900k都不一定全对。 由于图像识别存在误差,根本无法确定出错时间。更不用说被检测到了。

晓轩 20 Oct 27, 2022
Automatically fishes for you while you are afk :)

Dank-memer-afk-script A simple and quick way to make easy money in Dank Memer! How to use Open a discord channel which has the Dank Memer bot enabled.

Pranav Doshi 9 Nov 11, 2022
Converts an image into funny, smaller amongus characters

SussyImage Converts an image into funny, smaller amongus characters Demo Mona Lisa | Lona Misa (Made up of AmongUs characters) API I've also added an

Dhravya Shah 14 Aug 18, 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
QuanTaichi: A Compiler for Quantized Simulations (SIGGRAPH 2021)

QuanTaichi: A Compiler for Quantized Simulations (SIGGRAPH 2021) Yuanming Hu, Jiafeng Liu, Xuanda Yang, Mingkuan Xu, Ye Kuang, Weiwei Xu, Qiang Dai, W

Taichi Developers 119 Dec 02, 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
Python rubik's cube solver

This program makes a 3D representation of a rubiks cube and solves it step by step.

Pablo QB 4 May 29, 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
Pure Javascript OCR for more than 100 Languages 📖🎉🖥

Version 2 is now available and under development in the master branch, read a story about v2: Why I refactor tesseract.js v2? Check the support/1.x br

Project Naptha 29.2k Jan 05, 2023
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
Table recognition inside douments using neural networks

TableTrainNet A simple project for training and testing table recognition in documents. This project was developed to make a neural network which reco

Giovanni Cavallin 93 Jul 24, 2022
Source code of our TPAMI'21 paper Dual Encoding for Video Retrieval by Text and CVPR'19 paper Dual Encoding for Zero-Example Video Retrieval.

Dual Encoding for Video Retrieval by Text Source code of our TPAMI'21 paper Dual Encoding for Video Retrieval by Text and CVPR'19 paper Dual Encoding

81 Dec 01, 2022
Rotational region detection based on Faster-RCNN.

R2CNN_Faster_RCNN_Tensorflow Abstract This is a tensorflow re-implementation of R2CNN: Rotational Region CNN for Orientation Robust Scene Text Detecti

UCAS-Det 581 Nov 22, 2022
Code for the ACL2021 paper "Combining Static Word Embedding and Contextual Representations for Bilingual Lexicon Induction"

CSCBLI Code for our ACL Findings 2021 paper, "Combining Static Word Embedding and Contextual Representations for Bilingual Lexicon Induction". Require

Jinpeng Zhang 12 Oct 08, 2022
This is a passport scanning web service to help you scan, identify and validate your passport created with a simple and flexible design and ready to be integrated right into your system!

Passport-Recogniton-System This is a passport scanning web service to help you scan, identify and validate your passport created with a simple and fle

Mo'men Ashraf Muhamed 7 Jan 04, 2023
Détection de créneaux de vaccination disponibles pour l'outil ViteMaDose

Vite Ma Dose ! est un outil open source de CovidTracker permettant de détecter les rendez-vous disponibles dans votre département afin de vous faire v

CovidTracker 239 Dec 13, 2022
An unofficial package help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing

ZATCA (Fatoora) QR-Code Implementation An unofficial package help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicin

TheAwiteb 28 Nov 03, 2022
Demo for the paper "Overlap-aware low-latency online speaker diarization based on end-to-end local segmentation"

Streaming speaker diarization Overlap-aware low-latency online speaker diarization based on end-to-end local segmentation by Juan Manuel Coria, Hervé

Juanma Coria 185 Jan 01, 2023
An Agnostic Computer Vision Framework - Pluggable to any Training Library: Fastai, Pytorch-Lightning with more to come

An Agnostic Object Detection Framework IceVision is the first agnostic computer vision framework to offer a curated collection with hundreds of high-q

airctic 790 Jan 05, 2023
Fatigue Driving Detection Based on Dlib

Fatigue Driving Detection Based on Dlib

5 Dec 14, 2022