Skip to content

Commit

Permalink
Add --workers 8 argument to val.py (ultralytics#5857)
Browse files Browse the repository at this point in the history
* Update val.py

Add an option to choose number of workers if not called by train.py

* Update comment

* 120 char line width

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
iumyx2612 and glenn-jocher authored Dec 2, 2021
1 parent 00e308f commit 92a7391
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion val.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def run(data,
iou_thres=0.6, # NMS IoU threshold
task='val', # train, val, test, speed or study
device='', # cuda device, i.e. 0 or 0,1,2,3 or cpu
workers=8, # max dataloader workers (per RANK in DDP mode)
single_cls=False, # treat as single-class dataset
augment=False, # augmented inference
verbose=False, # verbose output
Expand Down Expand Up @@ -153,7 +154,7 @@ def run(data,
pad = 0.0 if task == 'speed' else 0.5
task = task if task in ('train', 'val', 'test') else 'val' # path to train/val/test images
dataloader = create_dataloader(data[task], imgsz, batch_size, stride, single_cls, pad=pad, rect=pt,
prefix=colorstr(f'{task}: '))[0]
workers=workers, prefix=colorstr(f'{task}: '))[0]

seen = 0
confusion_matrix = ConfusionMatrix(nc=nc)
Expand Down Expand Up @@ -312,6 +313,7 @@ def parse_opt():
parser.add_argument('--iou-thres', type=float, default=0.6, help='NMS IoU threshold')
parser.add_argument('--task', default='val', help='train, val, test, speed or study')
parser.add_argument('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--workers', type=int, default=8, help='max dataloader workers (per RANK in DDP mode)')
parser.add_argument('--single-cls', action='store_true', help='treat as single-class dataset')
parser.add_argument('--augment', action='store_true', help='augmented inference')
parser.add_argument('--verbose', action='store_true', help='report mAP by class')
Expand Down

0 comments on commit 92a7391

Please sign in to comment.