Roboflow Instant

Run a Roboflow Instant few-shot object detection model via the Serverless Hosted API.

Roboflow Instant is a few-shot object detection model that trains in minutes from a small set of labeled images. It is intended for rapid Proof of Concept work and supports Object Detection projects only. Learn how to train one in Roboflow Instant.

Once trained, an Instant model is available on the Serverless Hosted API using the same endpoint pattern as any other Roboflow model.

How to use it

You call your Roboflow Instant model by its model ID (<project-id>/<version>), the same way you would call a Roboflow 3.0 model. There are no preset/default Instant models. You must first train one inside your Workspace.

Confidence thresholds for Instant models can be sensitive. Optimal values typically range from 0.85 to 0.99 depending on the size of your training set.

Code sample

Install the Inference SDK and supervision:

pip install inference-sdk supervision

Pass your Roboflow API key via the API_KEY environment variable and replace your-instant-model-id/1 with your trained Instant model ID. The script below runs inference, converts the response into a sv.Detections object, draws bounding boxes and labels, and writes the annotated image to disk.

from inference_sdk import InferenceHTTPClient
import os
import cv2
import urllib.request
import supervision as sv

image_url = "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/cars-highway.png"
image_path = "cars-highway.png"
urllib.request.urlretrieve(image_url, image_path)

image = cv2.imread(image_path)

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key=os.getenv("API_KEY"),
)
results = client.infer(image, model_id="your-instant-model-id/1")

detections = sv.Detections.from_inference(results)

box_annotator = sv.BoxAnnotator()
label_annotator = sv.LabelAnnotator()

annotated_image = box_annotator.annotate(scene=image.copy(), detections=detections)
annotated_image = label_annotator.annotate(scene=annotated_image, detections=detections)

cv2.imwrite("annotated.png", annotated_image)

Set api_url to match your deployment target:

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

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

  • Your Dedicated Deployment URL for a private endpoint.

For more deployment options and self-hosting, see the Inference documentation.

Last updated

Was this helpful?