From 4daf4554315332eda39798d981662f154c708e3f Mon Sep 17 00:00:00 2001 From: JianWang <3432466@jabil.com> Date: Fri, 15 Sep 2023 11:40:45 +0800 Subject: [PATCH] add test yolov5 weights and image Signed-off-by: JianWang <3432466@jabil.com> --- export.py | 2 +- models/common.py | 4 ++-- utils/general.py | 6 +++--- utils/torch_utils.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/export.py b/export.py index 92d42472dfc4..59c4b679fdc2 100644 --- a/export.py +++ b/export.py @@ -197,7 +197,7 @@ def export_onnx(model, im, file, opset, dynamic, simplify, prefix=colorstr('ONNX LOGGER.info(f'{prefix} simplifying with onnx-simplifier {onnxsim.__version__}...') model_onnx, check = onnxsim.simplify(model_onnx) - assert check, 'assert check failed' + assert check, 'assets check failed' onnx.save(model_onnx, f) except Exception as e: LOGGER.info(f'{prefix} simplifier failure: {e}') diff --git a/models/common.py b/models/common.py index 75cc4e97bbc7..b8cc70098463 100644 --- a/models/common.py +++ b/models/common.py @@ -293,7 +293,7 @@ def __init__(self, gain=2): self.gain = gain def forward(self, x): - b, c, h, w = x.size() # assert (h / s == 0) and (W / s == 0), 'Indivisible gain' + b, c, h, w = x.size() # assets (h / s == 0) and (W / s == 0), 'Indivisible gain' s = self.gain x = x.view(b, c, h // s, s, w // s, s) # x(1,64,40,2,40,2) x = x.permute(0, 3, 5, 1, 2, 4).contiguous() # x(1,2,2,64,40,40) @@ -307,7 +307,7 @@ def __init__(self, gain=2): self.gain = gain def forward(self, x): - b, c, h, w = x.size() # assert C / s ** 2 == 0, 'Indivisible gain' + b, c, h, w = x.size() # assets C / s ** 2 == 0, 'Indivisible gain' s = self.gain x = x.view(b, s, s, c // s ** 2, h, w) # x(1,2,2,16,80,80) x = x.permute(0, 3, 4, 1, 5, 2).contiguous() # x(1,16,80,2,80,2) diff --git a/utils/general.py b/utils/general.py index 135141e21436..f6da6206cb68 100644 --- a/utils/general.py +++ b/utils/general.py @@ -392,7 +392,7 @@ def check_version(current='0.0.0', minimum='0.0.0', name='version ', pinned=Fals result = (current == minimum) if pinned else (current >= minimum) # bool s = f'WARNING ⚠️ {name}{minimum} is required by YOLOv5, but {name}{current} is currently installed' # string if hard: - assert result, emojis(s) # assert min requirements met + assert result, emojis(s) # assets min requirements met if verbose and not result: LOGGER.warning(s) return result @@ -465,8 +465,8 @@ def check_file(file, suffix=''): files = [] for d in 'data', 'models', 'utils': # search directories files.extend(glob.glob(str(ROOT / d / '**' / file), recursive=True)) # find file - 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 + assert len(files), f'File not found: {file}' # assets file was found + assert len(files) == 1, f"Multiple files match '{file}', specify exact path: {files}" # assets unique return files[0] # return file diff --git a/utils/torch_utils.py b/utils/torch_utils.py index 13a356f3238c..5ee0bd55cb99 100644 --- a/utils/torch_utils.py +++ b/utils/torch_utils.py @@ -114,7 +114,7 @@ def select_device(device='', batch_size=0, newline=True): if cpu or mps: os.environ['CUDA_VISIBLE_DEVICES'] = '-1' # force torch.cuda.is_available() = False elif device: # non-cpu device requested - os.environ['CUDA_VISIBLE_DEVICES'] = device # set environment variable - must be before assert is_available() + os.environ['CUDA_VISIBLE_DEVICES'] = device # set environment variable - must be before assets is_available() assert torch.cuda.is_available() and torch.cuda.device_count() >= len(device.replace(',', '')), \ f"Invalid CUDA '--device {device}' requested, use '--device cpu' or pass valid CUDA device(s)" @@ -425,7 +425,7 @@ def update(self, model): if v.dtype.is_floating_point: # true for FP16 and FP32 v *= d v += (1 - d) * msd[k].detach() - # assert v.dtype == msd[k].dtype == torch.float32, f'{k}: EMA {v.dtype} and model {msd[k].dtype} must be FP32' + # assets v.dtype == msd[k].dtype == torch.float32, f'{k}: EMA {v.dtype} and model {msd[k].dtype} must be FP32' def update_attr(self, model, include=(), exclude=('process_group', 'reducer')): # Update EMA attributes