From 0f395b3e3bccbc019ab3d1cbd41303a5b50dc0f0 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Sun, 11 Apr 2021 23:11:43 +0200 Subject: [PATCH] YOLOv5 v5.0 Release patch 1 (#2764) * torch.jit.trace(model, img, strict=False) * Update check_file() * Update hubconf.py * Update README.md --- README.md | 2 +- hubconf.py | 6 +++--- models/export.py | 2 +- utils/general.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 02908db0fd18..577c908de304 100755 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This repository represents Ultralytics open-source research into future object d Model |size
(pixels) |mAPval
0.5:0.95 |mAPtest
0.5:0.95 |mAPval
0.5 |Speed
V100 (ms) | |params
(M) |FLOPS
640 (B) --- |--- |--- |--- |--- |--- |---|--- |--- [YOLOv5s][assets] |640 |36.7 |36.7 |55.4 |**2.0** | |7.3 |17.0 -[YOLOv5m][assets] |640 |44.5 |44.5 |63.3 |2.7 | |21.4 |51.3 +[YOLOv5m][assets] |640 |44.5 |44.5 |63.1 |2.7 | |21.4 |51.3 [YOLOv5l][assets] |640 |48.2 |48.2 |66.9 |3.8 | |47.0 |115.4 [YOLOv5x][assets] |640 |**50.4** |**50.4** |**68.8** |6.1 | |87.7 |218.8 | | | | | | || | diff --git a/hubconf.py b/hubconf.py index d26db45695de..a2a43a7a10cb 100644 --- a/hubconf.py +++ b/hubconf.py @@ -1,4 +1,4 @@ -"""File for accessing YOLOv5 models via PyTorch Hub https://pytorch.org/hub/ultralytics_yolov5/ +"""YOLOv5 PyTorch Hub models https://pytorch.org/hub/ultralytics_yolov5/ Usage: import torch @@ -31,9 +31,9 @@ def create(name, pretrained, channels, classes, autoshape): Returns: pytorch model """ - config = Path(__file__).parent / 'models' / f'{name}.yaml' # model.yaml path try: - model = Model(config, channels, classes) + cfg = list((Path(__file__).parent / 'models').rglob(f'{name}.yaml'))[0] # model.yaml path + model = Model(cfg, channels, classes) if pretrained: fname = f'{name}.pt' # checkpoint filename attempt_download(fname) # download if not found locally diff --git a/models/export.py b/models/export.py index 11e60c7a583d..0bb5398e4841 100644 --- a/models/export.py +++ b/models/export.py @@ -62,7 +62,7 @@ try: print('\nStarting TorchScript export with torch %s...' % torch.__version__) f = opt.weights.replace('.pt', '.torchscript.pt') # filename - ts = torch.jit.trace(model, img) + ts = torch.jit.trace(model, img, strict=False) ts.save(f) print('TorchScript export success, saved as %s' % f) except Exception as e: diff --git a/utils/general.py b/utils/general.py index 5482629ac8c0..413eb5b8fa97 100755 --- a/utils/general.py +++ b/utils/general.py @@ -144,12 +144,12 @@ def check_imshow(): def check_file(file): # Search for file if not found - if os.path.isfile(file) or file == '': + if Path(file).is_file() or file == '': return file else: files = glob.glob('./**/' + file, recursive=True) # find file - assert len(files), 'File Not Found: %s' % file # assert file was found - assert len(files) == 1, "Multiple files match '%s', specify exact path: %s" % (file, files) # assert unique + assert len(files), f'File Not Found: {file}' # assert file was found + assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assert unique return files[0] # return file