YOLO-World
Use YOLO-World open-vocabulary object detection through our Serverless Hosted API
Code sample
curl --location 'https://serverless.roboflow.com/yolo_world/infer' \
--header 'Content-Type: application/json' \
--data '{
"api_key": "YOUR_API_KEY",
"image": {"type": "url", "value": "https://storage.googleapis.com/com-roboflow-marketing/notebooks/examples/cars-highway.png"},
"text": ["car", "truck"],
"yolo_world_version_id": "v2-s",
"confidence": 0.05
}'pip install inference-sdk supervisionimport os
import urllib.request
import cv2
import supervision as sv
from inference_sdk import InferenceHTTPClient
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)
client = InferenceHTTPClient(
api_url="https://serverless.roboflow.com",
api_key=os.getenv("API_KEY"),
)
results = client.infer_from_yolo_world(
inference_input=image_path,
class_names=["car", "truck"],
model_version="v2-s",
confidence=0.05,
)
detections = sv.Detections.from_inference(results[0])
image = cv2.imread(image_path)
labels = [
f"{name} {conf:.2f}"
for name, conf in zip(detections.data["class_name"], detections.confidence)
]
annotated = sv.BoxAnnotator().annotate(scene=image.copy(), detections=detections)
annotated = sv.LabelAnnotator().annotate(scene=annotated, detections=detections, labels=labels)
cv2.imwrite("annotated.png", annotated)
Last updated
Was this helpful?