|
| 1 | +from typing import Optional |
| 2 | + |
1 | 3 | from marshmallow import missing |
2 | 4 |
|
3 | 5 | import bioimageio.spec as spec |
|
6 | 8 | from bioimageio.core.resource_io.utils import resolve_source |
7 | 9 | from bioimageio.core.resource_tests import test_model as _test_model |
8 | 10 |
|
| 11 | +try: |
| 12 | + import tensorflow |
| 13 | +except ImportError: |
| 14 | + tf_version = None |
| 15 | +else: |
| 16 | + tf_version: Optional[str] = ".".join(tensorflow.__version__.split(".")[:2]) |
| 17 | + |
9 | 18 |
|
10 | 19 | def _test_build_spec( |
11 | 20 | spec_path, |
@@ -175,18 +184,18 @@ def test_build_spec_onnx(any_onnx_model, tmp_path): |
175 | 184 |
|
176 | 185 | def test_build_spec_keras(any_keras_model, tmp_path): |
177 | 186 | _test_build_spec( |
178 | | - any_keras_model, tmp_path / "model.zip", "keras_hdf5", tensorflow_version="1.12" |
| 187 | + any_keras_model, tmp_path / "model.zip", "keras_hdf5", tensorflow_version=tf_version |
179 | 188 | ) # todo: keras for tf 2?? |
180 | 189 |
|
181 | 190 |
|
182 | 191 | def test_build_spec_tf(any_tensorflow_model, tmp_path): |
183 | 192 | _test_build_spec( |
184 | | - any_tensorflow_model, tmp_path / "model.zip", "tensorflow_saved_model_bundle", tensorflow_version="1.12" |
| 193 | + any_tensorflow_model, tmp_path / "model.zip", "tensorflow_saved_model_bundle", tensorflow_version=tf_version |
185 | 194 | ) # check tf version |
186 | 195 |
|
187 | 196 |
|
188 | 197 | def test_build_spec_tfjs(any_tensorflow_js_model, tmp_path): |
189 | | - _test_build_spec(any_tensorflow_js_model, tmp_path / "model.zip", "tensorflow_js", tensorflow_version="1.12") |
| 198 | + _test_build_spec(any_tensorflow_js_model, tmp_path / "model.zip", "tensorflow_js", tensorflow_version=tf_version) |
190 | 199 |
|
191 | 200 |
|
192 | 201 | def test_build_spec_deepimagej(unet2d_nuclei_broad_model, tmp_path): |
@@ -220,7 +229,7 @@ def test_build_spec_parent2(unet2d_nuclei_broad_model, tmp_path): |
220 | 229 |
|
221 | 230 | def test_build_spec_deepimagej_keras(unet2d_keras, tmp_path): |
222 | 231 | _test_build_spec( |
223 | | - unet2d_keras, tmp_path / "model.zip", "keras_hdf5", add_deepimagej_config=True, tensorflow_version="1.12" |
| 232 | + unet2d_keras, tmp_path / "model.zip", "keras_hdf5", add_deepimagej_config=True, tensorflow_version=tf_version |
224 | 233 | ) |
225 | 234 |
|
226 | 235 |
|
|
0 commit comments