Add File Size (MB) column to benchmarks (#8359)
Browse files* Add filesize to benchmarks.py
* Add filesize to benchmarks.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- utils/benchmarks.py +5 -4
utils/benchmarks.py
CHANGED
@@ -41,7 +41,7 @@ if str(ROOT) not in sys.path:
|
|
41 |
import export
|
42 |
import val
|
43 |
from utils import notebook_init
|
44 |
-
from utils.general import LOGGER, check_yaml, print_args
|
45 |
from utils.torch_utils import select_device
|
46 |
|
47 |
|
@@ -75,10 +75,10 @@ def run(
|
|
75 |
result = val.run(data, w, batch_size, imgsz, plots=False, device=device, task='benchmark', half=half)
|
76 |
metrics = result[0] # metrics (mp, mr, map50, map, *losses(box, obj, cls))
|
77 |
speeds = result[2] # times (preprocess, inference, postprocess)
|
78 |
-
y.append([name, round(metrics[3], 4), round(speeds[1], 2)]) # mAP, t_inference
|
79 |
except Exception as e:
|
80 |
LOGGER.warning(f'WARNING: Benchmark failure for {name}: {e}')
|
81 |
-
y.append([name, None, None]) # mAP, t_inference
|
82 |
if pt_only and i == 0:
|
83 |
break # break after PyTorch
|
84 |
|
@@ -86,7 +86,8 @@ def run(
|
|
86 |
LOGGER.info('\n')
|
87 |
parse_opt()
|
88 |
notebook_init() # print system info
|
89 |
-
|
|
|
90 |
LOGGER.info(f'\nBenchmarks complete ({time.time() - t:.2f}s)')
|
91 |
LOGGER.info(str(py if map else py.iloc[:, :2]))
|
92 |
return py
|
|
|
41 |
import export
|
42 |
import val
|
43 |
from utils import notebook_init
|
44 |
+
from utils.general import LOGGER, check_yaml, file_size, print_args
|
45 |
from utils.torch_utils import select_device
|
46 |
|
47 |
|
|
|
75 |
result = val.run(data, w, batch_size, imgsz, plots=False, device=device, task='benchmark', half=half)
|
76 |
metrics = result[0] # metrics (mp, mr, map50, map, *losses(box, obj, cls))
|
77 |
speeds = result[2] # times (preprocess, inference, postprocess)
|
78 |
+
y.append([name, round(file_size(w), 1), round(metrics[3], 4), round(speeds[1], 2)]) # MB, mAP, t_inference
|
79 |
except Exception as e:
|
80 |
LOGGER.warning(f'WARNING: Benchmark failure for {name}: {e}')
|
81 |
+
y.append([name, None, None, None]) # mAP, t_inference
|
82 |
if pt_only and i == 0:
|
83 |
break # break after PyTorch
|
84 |
|
|
|
86 |
LOGGER.info('\n')
|
87 |
parse_opt()
|
88 |
notebook_init() # print system info
|
89 |
+
c = ['Format', 'Size (MB)', '[email protected]:0.95', 'Inference time (ms)'] if map else ['Format', 'Export', '', '']
|
90 |
+
py = pd.DataFrame(y, columns=c)
|
91 |
LOGGER.info(f'\nBenchmarks complete ({time.time() - t:.2f}s)')
|
92 |
LOGGER.info(str(py if map else py.iloc[:, :2]))
|
93 |
return py
|