* torch.jit.trace(model, img, strict=False) * Update check_file() * Update hubconf.py * Update README.mdmodifyDataloader
@@ -33,7 +33,7 @@ This repository represents Ultralytics open-source research into future object d | |||
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) | |||
--- |--- |--- |--- |--- |--- |---|--- |--- | |||
[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 | |||
| | | | | | || | |
@@ -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 |
@@ -62,7 +62,7 @@ if __name__ == '__main__': | |||
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: |
@@ -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 | |||