Skip to content

Commit d929c05

Browse files
committed
test_torchscript_to_onnx
1 parent 0728060 commit d929c05

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/test_weight_converters.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@ def test_pytorch_to_onnx(convert_to_onnx, tmp_path):
4848
assert summary.status == "passed", summary.display()
4949

5050

51+
def test_torchscript_to_onnx(unet2d_nuclei_broad_model, tmp_path):
52+
from bioimageio.core import test_model
53+
from bioimageio.core.weight_converters.torchscript_to_onnx import convert
54+
55+
model_descr = load_model_description(
56+
unet2d_nuclei_broad_model, format_version="latest"
57+
)
58+
out_path = tmp_path / "weights.onnx"
59+
opset_version = 18
60+
ret_val = convert(
61+
model_descr=model_descr,
62+
output_path=out_path,
63+
opset_version=opset_version,
64+
)
65+
assert os.path.exists(out_path)
66+
assert isinstance(ret_val, v0_5.OnnxWeightsDescr)
67+
assert ret_val.opset_version == opset_version
68+
assert ret_val.source == out_path
69+
70+
model_descr.weights.onnx = ret_val
71+
summary = test_model(model_descr, weight_format="onnx")
72+
assert summary.status == "passed", summary.display()
73+
74+
5175
@pytest.mark.skip()
5276
def test_keras_to_tensorflow(any_keras_model: Path, tmp_path: Path):
5377
from bioimageio.core import test_model

0 commit comments

Comments
 (0)