Fix export test matrices to exclude nms from Classify models (#18880)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
83dc1fea6e
commit
de05d1b655
3 changed files with 46 additions and 28 deletions
|
|
@ -44,18 +44,25 @@ def test_export_openvino():
|
|||
@pytest.mark.skipif(not TORCH_1_13, reason="OpenVINO requires torch>=1.13")
|
||||
@pytest.mark.parametrize(
|
||||
"task, dynamic, int8, half, batch, nms",
|
||||
[ # generate all combinations but exclude those where both int8 and half are True
|
||||
[ # generate all combinations except for exclusion cases
|
||||
(task, dynamic, int8, half, batch, nms)
|
||||
for task, dynamic, int8, half, batch, nms in product(
|
||||
TASKS, [True, False], [True, False], [True, False], [1, 2], [True, False]
|
||||
)
|
||||
if not (int8 and half) # exclude cases where both int8 and half are True
|
||||
if not ((int8 and half) or (task == "classify" and nms))
|
||||
],
|
||||
)
|
||||
def test_export_openvino_matrix(task, dynamic, int8, half, batch, nms):
|
||||
"""Test YOLO model exports to OpenVINO under various configuration matrix conditions."""
|
||||
file = YOLO(TASK2MODEL[task]).export(
|
||||
format="openvino", imgsz=32, dynamic=dynamic, int8=int8, half=half, batch=batch, data=TASK2DATA[task], nms=nms
|
||||
format="openvino",
|
||||
imgsz=32,
|
||||
dynamic=dynamic,
|
||||
int8=int8,
|
||||
half=half,
|
||||
batch=batch,
|
||||
data=TASK2DATA[task],
|
||||
nms=nms,
|
||||
)
|
||||
if WINDOWS:
|
||||
# Use unique filenames due to Windows file permissions bug possibly due to latent threaded use
|
||||
|
|
@ -69,7 +76,13 @@ def test_export_openvino_matrix(task, dynamic, int8, half, batch, nms):
|
|||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(
|
||||
"task, dynamic, int8, half, batch, simplify, nms",
|
||||
product(TASKS, [True, False], [False], [False], [1, 2], [True, False], [True, False]),
|
||||
[ # generate all combinations except for exclusion cases
|
||||
(task, dynamic, int8, half, batch, simplify, nms)
|
||||
for task, dynamic, int8, half, batch, simplify, nms in product(
|
||||
TASKS, [True, False], [False], [False], [1, 2], [True, False], [True, False]
|
||||
)
|
||||
if not ((int8 and half) or (task == "classify" and nms))
|
||||
],
|
||||
)
|
||||
def test_export_onnx_matrix(task, dynamic, int8, half, batch, simplify, nms):
|
||||
"""Test YOLO exports to ONNX format with various configurations and parameters."""
|
||||
|
|
@ -82,14 +95,19 @@ def test_export_onnx_matrix(task, dynamic, int8, half, batch, simplify, nms):
|
|||
|
||||
@pytest.mark.slow
|
||||
@pytest.mark.parametrize(
|
||||
"task, dynamic, int8, half, batch, nms", product(TASKS, [False], [False], [False], [1, 2], [True, False])
|
||||
"task, dynamic, int8, half, batch, nms",
|
||||
[ # generate all combinations except for exclusion cases
|
||||
(task, dynamic, int8, half, batch, nms)
|
||||
for task, dynamic, int8, half, batch, nms in product(TASKS, [False], [False], [False], [1, 2], [True, False])
|
||||
if not (task == "classify" and nms)
|
||||
],
|
||||
)
|
||||
def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms):
|
||||
"""Tests YOLO model exports to TorchScript format under varied configurations."""
|
||||
file = YOLO(TASK2MODEL[task]).export(
|
||||
format="torchscript", imgsz=32, dynamic=dynamic, int8=int8, half=half, batch=batch, nms=nms
|
||||
)
|
||||
YOLO(file)([SOURCE] * 3, imgsz=64 if dynamic else 32) # exported model inference at batch=3
|
||||
YOLO(file)([SOURCE] * batch, imgsz=64 if dynamic else 32) # exported model inference
|
||||
Path(file).unlink() # cleanup
|
||||
|
||||
|
||||
|
|
@ -99,10 +117,10 @@ def test_export_torchscript_matrix(task, dynamic, int8, half, batch, nms):
|
|||
@pytest.mark.skipif(checks.IS_PYTHON_3_12, reason="CoreML not supported in Python 3.12")
|
||||
@pytest.mark.parametrize(
|
||||
"task, dynamic, int8, half, batch",
|
||||
[ # generate all combinations but exclude those where both int8 and half are True
|
||||
[ # generate all combinations except for exclusion cases
|
||||
(task, dynamic, int8, half, batch)
|
||||
for task, dynamic, int8, half, batch in product(TASKS, [False], [True, False], [True, False], [1])
|
||||
if not (int8 and half) # exclude cases where both int8 and half are True
|
||||
if not (int8 and half)
|
||||
],
|
||||
)
|
||||
def test_export_coreml_matrix(task, dynamic, int8, half, batch):
|
||||
|
|
@ -124,12 +142,12 @@ def test_export_coreml_matrix(task, dynamic, int8, half, batch):
|
|||
@pytest.mark.skipif(not LINUX, reason="Test disabled as TF suffers from install conflicts on Windows and macOS")
|
||||
@pytest.mark.parametrize(
|
||||
"task, dynamic, int8, half, batch, nms",
|
||||
[ # generate all combinations but exclude those where both int8 and half are True
|
||||
[ # generate all combinations except for exclusion cases
|
||||
(task, dynamic, int8, half, batch, nms)
|
||||
for task, dynamic, int8, half, batch, nms in product(
|
||||
TASKS, [False], [True, False], [True, False], [1], [True, False]
|
||||
)
|
||||
if not (int8 and half) # exclude cases where both int8 and half are True
|
||||
if not ((int8 and half) or (task == "classify" and nms))
|
||||
],
|
||||
)
|
||||
def test_export_tflite_matrix(task, dynamic, int8, half, batch, nms):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue