Run a Model Locally
Run Roboflow models on your own hardware with a Docker inference server, in five minutes.
Run a model on your machine
3
Run the model
import base64
import cv2
import numpy as np
import requests
import supervision as sv
content = requests.get("https://media.roboflow.com/quickstart/cars.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
image_b64 = base64.b64encode(content).decode("utf-8")
result = requests.post(
"http://localhost:9001/coco/38", # coco/38 == rfdetr-nano
data=image_b64, # raw base64 in the body
headers={"Content-Type": "application/x-www-form-urlencoded"},
).json()
detections = sv.Detections.from_inference(result)
print(f"Found {len(detections)} objects")
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.jpg", annotated)3
Run the model
import cv2
import numpy as np
import requests
import supervision as sv
from inference_sdk import InferenceHTTPClient
content = requests.get("https://media.roboflow.com/quickstart/cars.jpg").content
image = cv2.imdecode(np.frombuffer(content, np.uint8), cv2.IMREAD_COLOR)
client = InferenceHTTPClient(api_url="http://localhost:9001")
result = client.infer(image, model_id="rfdetr-nano")
detections = sv.Detections.from_inference(result)
print(f"Found {len(detections)} objects")
annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)
cv2.imwrite("output.jpg", annotated)
Process a video
Other options
Last updated
Was this helpful?