|
|
|
@ -36,7 +36,7 @@ from ultralytics import YOLO |
|
|
|
|
from ultralytics.cfg import TASK2DATA, TASK2METRIC |
|
|
|
|
from ultralytics.engine.exporter import export_formats |
|
|
|
|
from ultralytics.utils import ASSETS, LINUX, LOGGER, MACOS, TQDM, WEIGHTS_DIR |
|
|
|
|
from ultralytics.utils.checks import check_requirements, check_yolo |
|
|
|
|
from ultralytics.utils.checks import IS_PYTHON_3_12, check_requirements, check_yolo |
|
|
|
|
from ultralytics.utils.files import file_size |
|
|
|
|
from ultralytics.utils.torch_utils import select_device |
|
|
|
|
|
|
|
|
@ -90,6 +90,8 @@ def benchmark( |
|
|
|
|
assert model.task != "obb", "TensorFlow GraphDef not supported for OBB task" |
|
|
|
|
elif i in {5, 10}: # CoreML and TF.js |
|
|
|
|
assert MACOS or LINUX, "export only supported on macOS and Linux" |
|
|
|
|
if i in {3, 5}: # CoreML and OpenVINO |
|
|
|
|
assert not IS_PYTHON_3_12, "CoreML and OpenVINO not supported on Python 3.12" |
|
|
|
|
if "cpu" in device.type: |
|
|
|
|
assert cpu, "inference not supported on CPU" |
|
|
|
|
if "cuda" in device.type: |
|
|
|
@ -147,8 +149,7 @@ class ProfileModels: |
|
|
|
|
""" |
|
|
|
|
ProfileModels class for profiling different models on ONNX and TensorRT. |
|
|
|
|
|
|
|
|
|
This class profiles the performance of different models, provided their paths. The profiling includes parameters such as |
|
|
|
|
model speed and FLOPs. |
|
|
|
|
This class profiles the performance of different models, returning results such as model speed and FLOPs. |
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
|
paths (list): Paths of the models to profile. |
|
|
|
@ -188,9 +189,9 @@ class ProfileModels: |
|
|
|
|
num_warmup_runs (int, optional): Number of warmup runs before the actual profiling starts. Default is 10. |
|
|
|
|
min_time (float, optional): Minimum time in seconds for profiling a model. Default is 60. |
|
|
|
|
imgsz (int, optional): Size of the image used during profiling. Default is 640. |
|
|
|
|
half (bool, optional): Flag to indicate whether to use half-precision floating point for profiling. Default is True. |
|
|
|
|
half (bool, optional): Flag to indicate whether to use half-precision floating point for profiling. |
|
|
|
|
trt (bool, optional): Flag to indicate whether to profile using TensorRT. Default is True. |
|
|
|
|
device (torch.device, optional): Device used for profiling. If None, it is determined automatically. Default is None. |
|
|
|
|
device (torch.device, optional): Device used for profiling. If None, it is determined automatically. |
|
|
|
|
""" |
|
|
|
|
self.paths = paths |
|
|
|
|
self.num_timed_runs = num_timed_runs |
|
|
|
|