forked from ultralytics/yolov5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New val.py
cuda
variable (ultralytics#6957)
* New val.py `cuda` variable Fix for ONNX GPU val. * Update val.py
- Loading branch information
1 parent
51d2a2c
commit 24d8af9
Showing
1 changed file
with
3 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,7 +143,7 @@ def run(data, | |
batch_size = model.batch_size | ||
else: | ||
device = model.device | ||
if not pt or jit: | ||
if not (pt or jit): | ||
batch_size = 1 # export.py models default to batch-size 1 | ||
LOGGER.info(f'Forcing --batch-size 1 square inference (1,3,{imgsz},{imgsz}) for non-PyTorch models') | ||
|
||
|
@@ -152,6 +152,7 @@ def run(data, | |
|
||
# Configure | ||
model.eval() | ||
cuda = device.type != 'cpu' | ||
is_coco = isinstance(data.get('val'), str) and data['val'].endswith('coco/val2017.txt') # COCO dataset | ||
nc = 1 if single_cls else int(data['nc']) # number of classes | ||
iouv = torch.linspace(0.5, 0.95, 10).to(device) # iou vector for [email protected]:0.95 | ||
|
@@ -177,7 +178,7 @@ def run(data, | |
pbar = tqdm(dataloader, desc=s, bar_format='{l_bar}{bar:10}{r_bar}{bar:-10b}') # progress bar | ||
for batch_i, (im, targets, paths, shapes) in enumerate(pbar): | ||
t1 = time_sync() | ||
if pt or jit or engine: | ||
if cuda: | ||
im = im.to(device, non_blocking=True) | ||
targets = targets.to(device) | ||
im = im.half() if half else im.float() # uint8 to fp16/32 | ||
|