run once to remove initial timing effects

This commit is contained in:
Glenn Jocher 2020-04-08 20:43:51 -07:00
parent b6959a2f54
commit 8f71b7865b
2 changed files with 2 additions and 0 deletions

View File

@ -75,6 +75,7 @@ def detect(save_img=False):
# Run inference
t0 = time.time()
_ = model(torch.zeros((1, 3, img_size, img_size), device=device)) if device.type != 'cpu' else None # run once
for path, img, im0s, vid_cap in dataset:
img = torch.from_numpy(img).to(device)
img = img.half() if half else img.float() # uint8 to fp16/32

View File

@ -70,6 +70,7 @@ def test(cfg,
seen = 0
model.eval()
_ = model(torch.zeros((1, 3, img_size, img_size), device=device)) if device.type != 'cpu' else None # run once
coco91class = coco80_to_coco91_class()
s = ('%20s' + '%10s' * 6) % ('Class', 'Images', 'Targets', 'P', 'R', 'mAP@0.5', 'F1')
p, r, f1, mp, mr, map, mf1, t0, t1 = 0., 0., 0., 0., 0., 0., 0., 0., 0.