@@ -154,22 +154,22 @@ def run(data,
154154 names = {k : v for k , v in enumerate (model .names if hasattr (model , 'names' ) else model .module .names )}
155155 class_map = coco80_to_coco91_class () if is_coco else list (range (1000 ))
156156 s = (
'%20s' + '%11s' * 6 )
% (
'Class' ,
'Images' ,
'Labels' ,
'P' ,
'R' ,
'[email protected] ' ,
'[email protected] :.95' )
157- p , r , f1 , mp , mr , map50 , map , t0 , t1 , t2 = 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0.
157+ dt , p , r , f1 , mp , mr , map50 , map = [ 0.0 , 0.0 , 0.0 ] , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0
158158 loss = torch .zeros (3 , device = device )
159159 jdict , stats , ap , ap_class = [], [], [], []
160160 for batch_i , (img , targets , paths , shapes ) in enumerate (tqdm (dataloader , desc = s )):
161- t_ = time_sync ()
161+ t1 = time_sync ()
162162 img = img .to (device , non_blocking = True )
163163 img = img .half () if half else img .float () # uint8 to fp16/32
164164 img /= 255.0 # 0 - 255 to 0.0 - 1.0
165165 targets = targets .to (device )
166166 nb , _ , height , width = img .shape # batch size, channels, height, width
167- t = time_sync ()
168- t0 += t - t_
167+ t2 = time_sync ()
168+ dt [ 0 ] += t2 - t1
169169
170170 # Run model
171171 out , train_out = model (img , augment = augment ) # inference and training outputs
172- t1 += time_sync () - t
172+ dt [ 1 ] += time_sync () - t2
173173
174174 # Compute loss
175175 if compute_loss :
@@ -178,9 +178,9 @@ def run(data,
178178 # Run NMS
179179 targets [:, 2 :] *= torch .Tensor ([width , height , width , height ]).to (device ) # to pixels
180180 lb = [targets [targets [:, 0 ] == i , 1 :] for i in range (nb )] if save_hybrid else [] # for autolabelling
181- t = time_sync ()
181+ t3 = time_sync ()
182182 out = non_max_suppression (out , conf_thres , iou_thres , labels = lb , multi_label = True , agnostic = single_cls )
183- t2 += time_sync () - t
183+ dt [ 2 ] += time_sync () - t3
184184
185185 # Statistics per image
186186 for si , pred in enumerate (out ):
@@ -247,7 +247,7 @@ def run(data,
247247 print (pf % (names [c ], seen , nt [c ], p [i ], r [i ], ap50 [i ], ap [i ]))
248248
249249 # Print speeds
250- t = tuple (x / seen * 1E3 for x in ( t0 , t1 , t2 ) ) # speeds per image
250+ t = tuple (x / seen * 1E3 for x in dt ) # speeds per image
251251 if not training :
252252 shape = (batch_size , 3 , imgsz , imgsz )
253253 print (f'Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape { shape } ' % t )
0 commit comments