@@ -16,7 +16,7 @@ def test_cli_test_model(unet2d_nuclei_broad_model):
16
16
assert ret .returncode == 0
17
17
18
18
19
- def test_cli_test_model_with_specific_weight_format (unet2d_nuclei_broad_model ):
19
+ def test_cli_test_model_with_weight_format (unet2d_nuclei_broad_model ):
20
20
ret = subprocess .run (
21
21
["bioimageio" , "test-model" , unet2d_nuclei_broad_model , "--weight-format" , "pytorch_state_dict" ]
22
22
)
@@ -28,25 +28,34 @@ def test_cli_test_resource(unet2d_nuclei_broad_model):
28
28
assert ret .returncode == 0
29
29
30
30
31
- def test_cli_test_resource_with_specific_weight_format (unet2d_nuclei_broad_model ):
31
+ def test_cli_test_resource_with_weight_format (unet2d_nuclei_broad_model ):
32
32
ret = subprocess .run (
33
33
["bioimageio" , "test-model" , unet2d_nuclei_broad_model , "--weight-format" , "pytorch_state_dict" ]
34
34
)
35
35
assert ret .returncode == 0
36
36
37
37
38
- def test_cli_predict_image ( unet2d_nuclei_broad_model , tmp_path ):
39
- spec = load_resource_description (unet2d_nuclei_broad_model )
38
+ def _test_cli_predict_image ( model , tmp_path , extra_kwargs = None ):
39
+ spec = load_resource_description (model )
40
40
in_path = spec .test_inputs [0 ]
41
41
out_path = tmp_path .with_suffix (".npy" )
42
- ret = subprocess .run (
43
- ["bioimageio" , "predict-image" , unet2d_nuclei_broad_model , "--inputs" , str (in_path ), "--outputs" , str (out_path )]
44
- )
42
+ cmd = ["bioimageio" , "predict-image" , model , "--inputs" , str (in_path ), "--outputs" , str (out_path )]
43
+ if extra_kwargs is not None :
44
+ cmd .extend (extra_kwargs )
45
+ ret = subprocess .run (cmd )
45
46
assert ret .returncode == 0
46
47
assert out_path .exists ()
47
48
48
49
49
- def test_cli_predict_images (unet2d_nuclei_broad_model , tmp_path ):
50
+ def test_cli_predict_image (unet2d_nuclei_broad_model , tmp_path ):
51
+ _test_cli_predict_image (unet2d_nuclei_broad_model , tmp_path )
52
+
53
+
54
+ def test_cli_predict_image_with_weight_format (unet2d_nuclei_broad_model , tmp_path ):
55
+ _test_cli_predict_image (unet2d_nuclei_broad_model , tmp_path , ["--weight-format" , "pytorch_state_dict" ])
56
+
57
+
58
+ def _test_cli_predict_images (model , tmp_path , extra_kwargs = None ):
50
59
n_images = 3
51
60
shape = (1 , 1 , 128 , 128 )
52
61
expected_shape = (1 , 1 , 128 , 128 )
@@ -64,14 +73,25 @@ def test_cli_predict_images(unet2d_nuclei_broad_model, tmp_path):
64
73
expected_outputs .append (out_folder / f"im-{ i } .npy" )
65
74
66
75
input_pattern = str (in_folder / "*.npy" )
67
- ret = subprocess .run (["bioimageio" , "predict-images" , unet2d_nuclei_broad_model , input_pattern , str (out_folder )])
76
+ cmd = ["bioimageio" , "predict-images" , model , input_pattern , str (out_folder )]
77
+ if extra_kwargs is not None :
78
+ cmd .extend (extra_kwargs )
79
+ ret = subprocess .run (cmd )
68
80
assert ret .returncode == 0
69
81
70
82
for out_path in expected_outputs :
71
83
assert out_path .exists ()
72
84
assert np .load (out_path ).shape == expected_shape
73
85
74
86
87
+ def test_cli_predict_images (unet2d_nuclei_broad_model , tmp_path ):
88
+ _test_cli_predict_images (unet2d_nuclei_broad_model , tmp_path )
89
+
90
+
91
+ def test_cli_predict_images_with_weight_format (unet2d_nuclei_broad_model , tmp_path ):
92
+ _test_cli_predict_images (unet2d_nuclei_broad_model , tmp_path , ["--weight-format" , "pytorch_state_dict" ])
93
+
94
+
75
95
def test_torch_to_torchscript (unet2d_nuclei_broad_model , tmp_path ):
76
96
out_path = tmp_path .with_suffix (".pt" )
77
97
ret = subprocess .run (
0 commit comments