Skip to content

Commit

Permalink
val.py --weights and --data compatibility check (#7292)
Browse files Browse the repository at this point in the history
Improved error messages for understanding of user error with val.py. May help #7291
  • Loading branch information
glenn-jocher committed Apr 5, 2022
1 parent 5f97001 commit d2e7ba2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions val.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def run(

# Dataloader
if not training:
if pt and not single_cls: # check --weights are trained on --data
ncm = model.model.yaml['nc']
assert ncm == nc, f'{weights[0]} ({ncm} classes) trained on different --data than what you passed ({nc} ' \
f'classes). Pass correct combination of --weights and --data that are trained together.'
model.warmup(imgsz=(1 if pt else batch_size, 3, imgsz, imgsz)) # warmup
pad = 0.0 if task in ('speed', 'benchmark') else 0.5
rect = False if task == 'benchmark' else pt # square inference for benchmarks
Expand Down

0 comments on commit d2e7ba2

Please sign in to comment.