For the complete documentation index, see llms.txt. This page is also available as Markdown.

Roboflow 3.0

Use the Roboflow 3.0 model family as a self-hosted model or through our Serverless Cloud API.

Roboflow 3.0 Object Detection

Roboflow 3.0 is Roboflow's in-house model architecture. You train Roboflow 3.0 models on the Roboflow platform and deploy them through the Serverless Cloud API. The sample below runs Roboflow's public COCO model (coco/3) so you can try it immediately. For self-hosted deployment, see Roboflow Inference.

Code sample

1

Get your API Key

Create a Roboflow account, find your key on the Roboflow API settings page and make it available to your shell:

export ROBOFLOW_API_KEY="your-key-here"
2

Install the dependencies

Install the Inference SDK and supervision:

pip install -U inference-sdk supervision
3

Run the model

Run detection on a sample image and annotate boxes and labels:

import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
result = client.infer(image, model_id="coco/3")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.png", annotated)

Set api_url to match your deployment target:

  • https://serverless.roboflow.com for the Serverless Cloud API.

  • http://localhost:9001 for a local Inference server.

  • Your Dedicated Deployment URL for a private endpoint.

Roboflow 3.0 Instance Segmentation

Train a Roboflow 3.0 instance segmentation model, then replace your-project/1 with your own {workspace}/{model-slug} ID (see Versions, Trainings, and Models). Set your API key and install the dependencies as shown above.

Code sample

import os
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient

image = sv.load_image_from_url("https://media.roboflow.com/quickstart/traffic.jpg")

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.environ["ROBOFLOW_API_KEY"],
)
# No pretrained aliases: train your own model and replace "your-project/1" with your model ID.
result = client.infer(image, model_id="your-project/1")

detections = sv.Detections.from_inference(result)

annotated = sv.MaskAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.png", annotated)

Roboflow 3.0 Keypoint Detection

This example runs the public rf-handpose hand keypoint model, then draws the 21-point hand skeleton. Swap in your own {workspace}/{model-slug}. Set your API key and install the dependencies as shown above.

Code sample

Roboflow 3.0 Classification

Classification responses contain a list of class predictions with confidences, so visualization is not applicable. Read the top class directly from the response. Replace your-project/1 with your trained model ID, and set your API key and install the dependencies as shown above.

Code sample

Last updated

Was this helpful?