Unverified 提交 f4197214 authored 作者: Glenn Jocher's avatar Glenn Jocher 提交者: GitHub

Update test.py --task train val study (#2453)

* Update test.py --task train val study * update argparser --task
上级 f01f3223
...@@ -85,9 +85,9 @@ def test(data, ...@@ -85,9 +85,9 @@ def test(data,
if not training: if not training:
if device.type != 'cpu': if device.type != 'cpu':
model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once model(torch.zeros(1, 3, imgsz, imgsz).to(device).type_as(next(model.parameters()))) # run once
path = data['test'] if opt.task == 'test' else data['val'] # path to val/test images task = opt.task if opt.task in ('train', 'val', 'test') else 'val' # path to train/val/test images
dataloader = create_dataloader(path, imgsz, batch_size, gs, opt, pad=0.5, rect=True, dataloader = create_dataloader(data[task], imgsz, batch_size, gs, opt, pad=0.5, rect=True,
prefix=colorstr('test: ' if opt.task == 'test' else 'val: '))[0] prefix=colorstr(f'{task}: '))[0]
seen = 0 seen = 0
confusion_matrix = ConfusionMatrix(nc=nc) confusion_matrix = ConfusionMatrix(nc=nc)
...@@ -287,7 +287,7 @@ if __name__ == '__main__': ...@@ -287,7 +287,7 @@ if __name__ == '__main__':
parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)') parser.add_argument('--img-size', type=int, default=640, help='inference size (pixels)')
parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold') parser.add_argument('--conf-thres', type=float, default=0.001, help='object confidence threshold')
parser.add_argument('--iou-thres', type=float, default=0.6, help='IOU threshold for NMS') parser.add_argument('--iou-thres', type=float, default=0.6, help='IOU threshold for NMS')
parser.add_argument('--task', default='val', help="'val', 'test', 'study'") 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('--device', default='', help='cuda device, i.e. 0 or 0,1,2,3 or cpu')
parser.add_argument('--single-cls', action='store_true', help='treat as single-class dataset') 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('--augment', action='store_true', help='augmented inference')
...@@ -305,7 +305,7 @@ if __name__ == '__main__': ...@@ -305,7 +305,7 @@ if __name__ == '__main__':
print(opt) print(opt)
check_requirements() check_requirements()
if opt.task in ['val', 'test']: # run normally if opt.task in ('train', 'val', 'test'): # run normally
test(opt.data, test(opt.data,
opt.weights, opt.weights,
opt.batch_size, opt.batch_size,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论