glenn-jocher commited on
Commit
2bcc89d
1 Parent(s): e5b0200

YOLOv5 PyTorch Hub models >> check_requirements() (#2577)

Browse files

* 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

Files changed (1) hide show
  1. hubconf.py +4 -3
hubconf.py CHANGED
@@ -1,8 +1,8 @@
1
- """File for accessing YOLOv5 via PyTorch Hub https://pytorch.org/hub/
2
 
3
  Usage:
4
  import torch
5
- model = torch.hub.load('ultralytics/yolov5', 'yolov5s', pretrained=True, channels=3, classes=80)
6
  """
7
 
8
  from pathlib import Path
@@ -10,11 +10,12 @@ from pathlib import Path
10
  import torch
11
 
12
  from models.yolo import Model
13
- from utils.general import set_logging
14
  from utils.google_utils import attempt_download
15
  from utils.torch_utils import select_device
16
 
17
  dependencies = ['torch', 'yaml']
 
18
  set_logging()
19
 
20
 
 
1
+ """File for accessing YOLOv5 models via PyTorch Hub https://pytorch.org/hub/ultralytics_yolov5/
2
 
3
  Usage:
4
  import torch
5
+ model = torch.hub.load('ultralytics/yolov5', 'yolov5s')
6
  """
7
 
8
  from pathlib import Path
 
10
  import torch
11
 
12
  from models.yolo import Model
13
+ from utils.general import check_requirements, set_logging
14
  from utils.google_utils import attempt_download
15
  from utils.torch_utils import select_device
16
 
17
  dependencies = ['torch', 'yaml']
18
+ check_requirements(exclude=('pycocotools', 'thop'))
19
  set_logging()
20
 
21