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

YOLOv5

Use the YOLOv5 model family through our Serverless Cloud API

Existing YOLOv5 models remain available through the Serverless Cloud API and self-hosted Inference. New weight uploads and training for YOLOv5 are not supported on Roboflow. For supported upload families, see Upload Custom Weights.

YOLOv5 input size is set when you train your model outside Roboflow (typical values: 640x640 or 1280x1280).

YOLOv5 API

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 SDK and supervision for decoding and annotation:

pip install -U inference-sdk supervision
3

Run the model

Swap in the {workspace}/{model-slug} ID of an existing uploaded YOLOv5 model (see Versions, Trainings, and Models).

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

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"],
).configure(InferenceConfiguration(api_key_transport="header"))
result = client.infer(image, model_id="your-workspace/your-model-slug")

detections = sv.Detections.from_inference(result)

annotated = sv.BoxAnnotator().annotate(image.copy(), detections)
annotated = sv.LabelAnnotator().annotate(annotated, detections)

cv2.imwrite("annotated.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.

License

YOLOv5 is released under AGPL-3.0. What that means for commercial use:

  • On Roboflow cloud: a commercial license is included for every user, including the free plan.

  • Self-hosted: you need the Enterprise license add-on, or you must open-source your application under AGPL-3.0.

  • Permissive alternative: RF-DETR is Apache 2.0, free for commercial use anywhere.

See Roboflow's Ultralytics licensing for details.

Last updated

Was this helpful?