glenn-jocher commited on
Commit
0f395b3
1 Parent(s): f5b8f7d

YOLOv5 v5.0 Release patch 1 (#2764)

Browse files

* torch.jit.trace(model, img, strict=False)

* Update check_file()

* Update hubconf.py

* Update README.md

Files changed (4) hide show
  1. README.md +1 -1
  2. hubconf.py +3 -3
  3. models/export.py +1 -1
  4. utils/general.py +3 -3
README.md CHANGED
@@ -33,7 +33,7 @@ This repository represents Ultralytics open-source research into future object d
33
  Model |size<br><sup>(pixels) |mAP<sup>val<br>0.5:0.95 |mAP<sup>test<br>0.5:0.95 |mAP<sup>val<br>0.5 |Speed<br><sup>V100 (ms) | |params<br><sup>(M) |FLOPS<br><sup>640 (B)
34
  --- |--- |--- |--- |--- |--- |---|--- |---
35
  [YOLOv5s][assets] |640 |36.7 |36.7 |55.4 |**2.0** | |7.3 |17.0
36
- [YOLOv5m][assets] |640 |44.5 |44.5 |63.3 |2.7 | |21.4 |51.3
37
  [YOLOv5l][assets] |640 |48.2 |48.2 |66.9 |3.8 | |47.0 |115.4
38
  [YOLOv5x][assets] |640 |**50.4** |**50.4** |**68.8** |6.1 | |87.7 |218.8
39
  | | | | | | || |
 
33
  Model |size<br><sup>(pixels) |mAP<sup>val<br>0.5:0.95 |mAP<sup>test<br>0.5:0.95 |mAP<sup>val<br>0.5 |Speed<br><sup>V100 (ms) | |params<br><sup>(M) |FLOPS<br><sup>640 (B)
34
  --- |--- |--- |--- |--- |--- |---|--- |---
35
  [YOLOv5s][assets] |640 |36.7 |36.7 |55.4 |**2.0** | |7.3 |17.0
36
+ [YOLOv5m][assets] |640 |44.5 |44.5 |63.1 |2.7 | |21.4 |51.3
37
  [YOLOv5l][assets] |640 |48.2 |48.2 |66.9 |3.8 | |47.0 |115.4
38
  [YOLOv5x][assets] |640 |**50.4** |**50.4** |**68.8** |6.1 | |87.7 |218.8
39
  | | | | | | || |
hubconf.py CHANGED
@@ -1,4 +1,4 @@
1
- """File for accessing YOLOv5 models via PyTorch Hub https://pytorch.org/hub/ultralytics_yolov5/
2
 
3
  Usage:
4
  import torch
@@ -31,9 +31,9 @@ def create(name, pretrained, channels, classes, autoshape):
31
  Returns:
32
  pytorch model
33
  """
34
- config = Path(__file__).parent / 'models' / f'{name}.yaml' # model.yaml path
35
  try:
36
- model = Model(config, channels, classes)
 
37
  if pretrained:
38
  fname = f'{name}.pt' # checkpoint filename
39
  attempt_download(fname) # download if not found locally
 
1
+ """YOLOv5 PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5/
2
 
3
  Usage:
4
  import torch
 
31
  Returns:
32
  pytorch model
33
  """
 
34
  try:
35
+ cfg = list((Path(__file__).parent / 'models').rglob(f'{name}.yaml'))[0] # model.yaml path
36
+ model = Model(cfg, channels, classes)
37
  if pretrained:
38
  fname = f'{name}.pt' # checkpoint filename
39
  attempt_download(fname) # download if not found locally
models/export.py CHANGED
@@ -62,7 +62,7 @@ if __name__ == '__main__':
62
  try:
63
  print('\nStarting TorchScript export with torch %s...' % torch.__version__)
64
  f = opt.weights.replace('.pt', '.torchscript.pt') # filename
65
- ts = torch.jit.trace(model, img)
66
  ts.save(f)
67
  print('TorchScript export success, saved as %s' % f)
68
  except Exception as e:
 
62
  try:
63
  print('\nStarting TorchScript export with torch %s...' % torch.__version__)
64
  f = opt.weights.replace('.pt', '.torchscript.pt') # filename
65
+ ts = torch.jit.trace(model, img, strict=False)
66
  ts.save(f)
67
  print('TorchScript export success, saved as %s' % f)
68
  except Exception as e:
utils/general.py CHANGED
@@ -144,12 +144,12 @@ def check_imshow():
144
 
145
  def check_file(file):
146
  # Search for file if not found
147
- if os.path.isfile(file) or file == '':
148
  return file
149
  else:
150
  files = glob.glob('./**/' + file, recursive=True) # find file
151
- assert len(files), 'File Not Found: %s' % file # assert file was found
152
- assert len(files) == 1, "Multiple files match '%s', specify exact path: %s" % (file, files) # assert unique
153
  return files[0] # return file
154
 
155
 
 
144
 
145
  def check_file(file):
146
  # Search for file if not found
147
+ if Path(file).is_file() or file == '':
148
  return file
149
  else:
150
  files = glob.glob('./**/' + file, recursive=True) # find file
151
+ assert len(files), f'File Not Found: {file}' # assert file was found
152
+ assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assert unique
153
  return files[0] # return file
154
 
155