Implementation:Obss Sahi Download Yolov5 Model
| Knowledge Sources | |
|---|---|
| Domains | Object_Detection, Model_Setup |
| Last Updated | 2026-02-08 12:00 GMT |
Overview
Utility functions for downloading YOLOv5 model weights (Nano, Small-P6, Medium-P6 variants) from Ultralytics releases.
Description
The sahi.utils.yolov5 module provides convenience functions for downloading YOLOv5 model weights. Yolov5TestConstants defines download URLs and default local paths for YOLOv5n (v6.0), YOLOv5s6 (v5.0), and YOLOv5m6 (v5.0) model variants. Each download function checks if the file already exists before downloading, and creates parent directories as needed.
Usage
Use these functions to obtain YOLOv5 model weights before initializing the YOLOv5 detection model in SAHI, particularly in test environments or first-time setup.
Code Reference
Source Location
- Repository: Obss_Sahi
- File: sahi/utils/yolov5.py
- Lines: 1-42
Signature
class Yolov5TestConstants:
YOLOV5N_MODEL_URL: str
YOLOV5N_MODEL_PATH: str
YOLOV5S6_MODEL_URL: str
YOLOV5S6_MODEL_PATH: str
YOLOV5M6_MODEL_URL: str
YOLOV5M6_MODEL_PATH: str
def download_yolov5n_model(destination_path: str | None = None) -> None: ...
def download_yolov5s6_model(destination_path: str | None = None) -> None: ...
Import
from sahi.utils.yolov5 import download_yolov5n_model, download_yolov5s6_model, Yolov5TestConstants
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| destination_path | str or None | No | Custom download path; defaults to tests/data/models/yolov5/ |
Outputs
| Name | Type | Description |
|---|---|---|
| Model file | .pt file | YOLOv5 model weights at destination path |
Usage Examples
Download YOLOv5 Models
from sahi.utils.yolov5 import download_yolov5n_model, download_yolov5s6_model
# Download YOLOv5n to default test path
download_yolov5n_model()
# Download YOLOv5s6 to custom path
download_yolov5s6_model(destination_path="/models/yolov5s6.pt")