Links

Active Learning

Automate improvement of your dataset by using computer vision and conditional upload logic to determine which images should be directly uploaded to your Roboflow workspace

Pip Package Installation

To install dependencies, pip install roboflow

Function Parameters

def active_learning(
self,
raw_data_location: str = "",
raw_data_extension: str = "",
inference_endpoint: list = [],
upload_destination: str = "",
conditionals: dict = {},
use_localhost: bool = False,
) -> str:
"""perform inference on each image in directory and upload based on conditions
@params:
raw_data_location: (str) = folder of frames to be processed
raw_data_extension: (str) = extension of frames to be processed
inference_endpoint: (List[str, int]) = name of the project
upload_destination: (str) = name of the upload project
conditionals: (dict) = dictionary of upload conditions
use_localhost: (bool) = determines if local http format used or remote endpoint
"""

Conditionals

{
"similarity_confidence_threshold": 0-1, #the similarity the next uploaded inference must be less than
"similarity_timeout_counter: N, #the number of frames to reupload anyways even if similarity reqs are not met
"required_objects_count": N, #the model must predict more objects than this to upload
"required_class_count": N, #the number of boxes of a class required to upload
"target_classes": CLASS_NAME, #the class to target, only images with classes greater than this will be uploaded
"confidence_interval" [0,1], #the confidence all preds must fall into
"minimum_size_requirement": N, #minimum number of pixels all pred boxes must have,
"maximum_size_requirment":N #maximum number of pixels all pred boxes must have,
}

Working example that uses remote endpoint

active_learning.py
from roboflow import Roboflow
# obtaining your API key: https://docs.roboflow.com/rest-api#obtaining-your-api-key
rf = Roboflow(api_key="INSERT_PRIVATE_API_KEY")
workspace = rf.workspace()
raw_data_location = "INSERT_PATH_TO_IMAGES"
raw_data_extension = ".jpg"
# replace * with your model version number for inference
inference_endpoint = ["INSERT_MODEL_ID", *]
upload_destination = "INSERT_MODEL_ID"
# set the conditionals values as necessary for your active learning needs
# NOTE - not all conditional fields are required
conditionals = {
"required_objects_count" : 1,
"required_class_count": 1,
"target_classes": [],
"minimum_size_requirement" : float('-inf'),
"maximum_size_requirement" : float('inf'),
"confidence_interval" : [10,90],
}
# filtering out images for upload by similarity is available for paid plans
# contact the Roboflow team for access: https://roboflow.com/sales
# conditionals = {
# "required_objects_count" : 1,
# "required_class_count": 1,
# "target_classes": [],
# "minimum_size_requirement" : float('-inf'),
# "maximum_size_requirement" : float('inf'),
# "confidence_interval" : [10,90],
# "similarity_confidence_threshold": .3,
# "similarity_timeout_limit": 3
# }
workspace.active_learning(raw_data_location=raw_data_location,
raw_data_extension=raw_data_extension,
inference_endpoint=inference_endpoint,
upload_destination=upload_destination,
conditionals=conditionals)

Referencing a Locally Running Inference Server for Active Learning

A single local inference server must be running and available for communication before executing the python script!
Update use_localhost to True , it will then automatically detect and point at the locally running Roboflow inference server.
workspace.active_learning(raw_data_location=raw_data_location,
raw_data_extension=raw_data_extension,
inference_endpoint=inference_endpoint,
upload_destination=upload_destination,
conditionals=conditionals,
use_localhost=True)