From 0a7324f0bc61ce15b8ceba3d12c163d88eab50f9 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 24 Mar 2021 15:42:00 +0100 Subject: [PATCH] YOLOv5 PyTorch Hub models >> check_requirements() (#2577) * Update hubconf.py with check_requirements() Dependency checks have been missing from YOLOv5 PyTorch Hub model loading, causing errors in some cases when users are attempting to import hub models in unsupported environments. This should examine the YOLOv5 requirements.txt file and pip install any missing or version-conflict packages encountered. This is highly experimental (!), please let us know if this creates problems in your custom workflows. * Update hubconf.py (cherry picked from commit 2bcc89d76225a704bb9a21c926bd28ef7847d81d) --- hubconf.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hubconf.py b/hubconf.py index b7b740d39c06..4b4ae04cf332 100644 --- a/hubconf.py +++ b/hubconf.py @@ -1,8 +1,8 @@ -"""File for accessing YOLOv5 via PyTorch Hub https://pytorch.org/hub/ +"""File for accessing YOLOv5 models via PyTorch Hub https://pytorch.org/hub/ultralytics_yolov5/ Usage: import torch - model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True, channels=3, classes=80) + model = torch.hub.load('ultralytics/yolov5', 'yolov5s') """ from pathlib import Path @@ -10,11 +10,12 @@ import torch from models.yolo import Model -from utils.general import set_logging +from utils.general import check_requirements, set_logging from utils.google_utils import attempt_download from utils.torch_utils import select_device dependencies = ['torch', 'yaml'] +check_requirements(exclude=('pycocotools', 'thop')) set_logging()