Skip to content

Commit

Permalink
Merge pull request ultralytics#1 from LeBron-Jian/james
Browse files Browse the repository at this point in the history
add test yolov5 weights and image
  • Loading branch information
LeBron-Jian committed Sep 15, 2023
2 parents 9e97ac3 + 4daf455 commit 3d7fc08
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion export.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
4 changes: 2 additions & 2 deletions models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
4 changes: 2 additions & 2 deletions utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3d7fc08

Please sign in to comment.