glenn-jocher
commited on
Update detections() self.t = tuple() (#2617)
Browse files* Update detections() self.t = tuple()
Fix multiple results.print() bug.
* Update experimental.py
* Update yolo.py
- models/common.py +3 -4
- models/experimental.py +1 -1
- models/yolo.py +2 -0
models/common.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
|
3 |
import math
|
4 |
from pathlib import Path
|
@@ -248,7 +248,7 @@ class Detections:
|
|
248 |
self.xyxyn = [x / g for x, g in zip(self.xyxy, gn)] # xyxy normalized
|
249 |
self.xywhn = [x / g for x, g in zip(self.xywh, gn)] # xywh normalized
|
250 |
self.n = len(self.pred)
|
251 |
-
self.t = ((times[i + 1] - times[i]) * 1000 / self.n for i in range(3)) # timestamps (ms)
|
252 |
self.s = shape # inference BCHW shape
|
253 |
|
254 |
def display(self, pprint=False, show=False, save=False, render=False, save_dir=''):
|
@@ -277,8 +277,7 @@ class Detections:
|
|
277 |
|
278 |
def print(self):
|
279 |
self.display(pprint=True) # print results
|
280 |
-
print(f'Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {tuple(self.s)}' %
|
281 |
-
tuple(self.t))
|
282 |
|
283 |
def show(self):
|
284 |
self.display(show=True) # show results
|
|
|
1 |
+
# YOLOv5 common modules
|
2 |
|
3 |
import math
|
4 |
from pathlib import Path
|
|
|
248 |
self.xyxyn = [x / g for x, g in zip(self.xyxy, gn)] # xyxy normalized
|
249 |
self.xywhn = [x / g for x, g in zip(self.xywh, gn)] # xywh normalized
|
250 |
self.n = len(self.pred)
|
251 |
+
self.t = tuple((times[i + 1] - times[i]) * 1000 / self.n for i in range(3)) # timestamps (ms)
|
252 |
self.s = shape # inference BCHW shape
|
253 |
|
254 |
def display(self, pprint=False, show=False, save=False, render=False, save_dir=''):
|
|
|
277 |
|
278 |
def print(self):
|
279 |
self.display(pprint=True) # print results
|
280 |
+
print(f'Speed: %.1fms pre-process, %.1fms inference, %.1fms NMS per image at shape {tuple(self.s)}' % self.t)
|
|
|
281 |
|
282 |
def show(self):
|
283 |
self.display(show=True) # show results
|
models/experimental.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
#
|
2 |
|
3 |
import numpy as np
|
4 |
import torch
|
|
|
1 |
+
# YOLOv5 experimental modules
|
2 |
|
3 |
import numpy as np
|
4 |
import torch
|
models/yolo.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import argparse
|
2 |
import logging
|
3 |
import sys
|
|
|
1 |
+
# YOLOv5 YOLO-specific modules
|
2 |
+
|
3 |
import argparse
|
4 |
import logging
|
5 |
import sys
|