Fix ONNX export by passing workspace parameter only for engine format
This commit is contained in:
parent
c87450393e
commit
1a8d1678d2
2 changed files with 41 additions and 11 deletions
|
|
@ -247,16 +247,19 @@ def main(argv: Sequence[str] | None = None) -> int:
|
|||
flush=True,
|
||||
)
|
||||
|
||||
exported_path = model.export(
|
||||
format=config.export_format,
|
||||
imgsz=config.imgsz,
|
||||
half=config.half,
|
||||
int8=config.int8,
|
||||
dynamic=config.dynamic,
|
||||
simplify=config.simplify,
|
||||
batch=config.batch,
|
||||
workspace=config.workspace,
|
||||
)
|
||||
export_kwargs: dict[str, Any] = {
|
||||
"format": config.export_format,
|
||||
"imgsz": config.imgsz,
|
||||
"half": config.half,
|
||||
"int8": config.int8,
|
||||
"dynamic": config.dynamic,
|
||||
"simplify": config.simplify,
|
||||
"batch": config.batch,
|
||||
}
|
||||
if config.export_format in ("engine", "tensorrt", "trt"):
|
||||
export_kwargs["workspace"] = config.workspace
|
||||
|
||||
exported_path = model.export(**export_kwargs)
|
||||
result_path = _result_path(exported_path)
|
||||
|
||||
print("Экспорт завершен успешно.", flush=True)
|
||||
|
|
|
|||
|
|
@ -88,12 +88,39 @@ def test_main_validates_config_and_reports_existing_export(
|
|||
"dynamic": True,
|
||||
"simplify": True,
|
||||
"batch": 2,
|
||||
"workspace": 2.5,
|
||||
}
|
||||
]
|
||||
assert f"__YOLO_WEBUI_RESULT__:{result}" in output.out
|
||||
|
||||
|
||||
def test_main_passes_workspace_only_for_engine_format(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
tmp_path: Path,
|
||||
) -> None:
|
||||
model = _write_model(tmp_path, monkeypatch)
|
||||
result = tmp_path / "models" / "model.engine"
|
||||
result.write_bytes(b"engine")
|
||||
_, export_calls = _install_fake_ultralytics(monkeypatch, result)
|
||||
config = _write_config(
|
||||
tmp_path,
|
||||
{
|
||||
"model": model.name,
|
||||
"format": "engine",
|
||||
"imgsz": 640,
|
||||
"half": False,
|
||||
"int8": False,
|
||||
"dynamic": False,
|
||||
"simplify": True,
|
||||
"batch": 1,
|
||||
"workspace": 4.0,
|
||||
},
|
||||
)
|
||||
|
||||
return_code = export_runner.main([str(config)])
|
||||
assert return_code == 0
|
||||
assert export_calls[0]["workspace"] == 4.0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"override",
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue