Roboflow Instant
Run a Roboflow Instant few-shot object detection model via the Serverless Hosted API.
How to use it
Code sample
pip install inference-sdk supervisionfrom 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)Last updated
Was this helpful?