diff --git a/bioimageio/spec/model/v0_5.py b/bioimageio/spec/model/v0_5.py index 0e0bf3c61..9da8002d7 100644 --- a/bioimageio/spec/model/v0_5.py +++ b/bioimageio/spec/model/v0_5.py @@ -333,8 +333,6 @@ class AxisBase(NodeWithExplicitlySetFields): description: Annotated[str, MaxLen(128)] = "" - __hash__ = NodeWithExplicitlySetFields.__hash__ - class WithHalo(Node): halo: Annotated[int, Ge(0)] = 0 diff --git a/example_descriptions/models/stardist_example_model/rdf_v0_4.yaml b/example_descriptions/models/stardist_example_model/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/stardist_example_model/rdf_v0_4.yaml rename to example_descriptions/models/stardist_example_model/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_diff_output_shape/rdf_v0_4.yaml b/example_descriptions/models/unet2d_diff_output_shape/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/unet2d_diff_output_shape/rdf_v0_4.yaml rename to example_descriptions/models/unet2d_diff_output_shape/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_fixed_shape/rdf_v0_4.yaml b/example_descriptions/models/unet2d_fixed_shape/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/unet2d_fixed_shape/rdf_v0_4.yaml rename to example_descriptions/models/unet2d_fixed_shape/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_keras_tf/rdf_v0_4.yaml b/example_descriptions/models/unet2d_keras_tf/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/unet2d_keras_tf/rdf_v0_4.yaml rename to example_descriptions/models/unet2d_keras_tf/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_keras_tf2/rdf_v0_4.yaml b/example_descriptions/models/unet2d_keras_tf2/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/unet2d_keras_tf2/rdf_v0_4.yaml rename to example_descriptions/models/unet2d_keras_tf2/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_multi_tensor/rdf_v0_4.yaml b/example_descriptions/models/unet2d_multi_tensor/v0_4.bioimageio.yaml similarity index 100% rename from example_descriptions/models/unet2d_multi_tensor/rdf_v0_4.yaml rename to example_descriptions/models/unet2d_multi_tensor/v0_4.bioimageio.yaml diff --git a/example_descriptions/models/unet2d_nuclei_broad/rdf.yaml.wip b/example_descriptions/models/unet2d_nuclei_broad/rdf.yaml.wip deleted file mode 100644 index 1b7baa64c..000000000 --- a/example_descriptions/models/unet2d_nuclei_broad/rdf.yaml.wip +++ /dev/null @@ -1,94 +0,0 @@ -format_version: 0.4.9 - -name: UNet 2D Nuclei Broad -description: A 2d U-Net trained on the nuclei broad dataset. -authors: -- name: "Constantin Pape;@bioimage-io" - affiliation: "EMBL Heidelberg" - orcid: "0000-0001-6562-7187" -- name: "Fynn Beuttenmueller" - affiliation: "EMBL Heidelberg" - orcid: "0000-0002-8567-6389" -maintainers: -- name: "Constantin Pape" - github_user: constantinpape -- name: "Fynn Beuttenmueller" - github_user: fynnbe - -# we allow for multiple citations. Each citation contains TEXT, DOI and URL. One of DOI or URL needs to be given. -cite: -- text: "Ronneberger, Olaf et al. U-net: Convolutional networks for biomedical image segmentation. MICCAI 2015." - doi: https://doi.org/10.1007/978-3-319-24574-4_28 -- text: "2018 Data Science Bowl" - url: https://www.kaggle.com/c/data-science-bowl-2018 - -git_repo: https://github.com/bioimage-io/spec-bioimage-io/tree/main/example_descriptions/models/unet2d_nuclei_broad -tags: [unet2d, pytorch, nucleus, segmentation, dsb2018] -license: MIT - -documentation: README.md # may also be a url -covers: [cover0.png] -attachments: {} -timestamp: 2019-12-11T12:22:32Z # ISO 8601 - -inputs: -- name: raw - description: raw input - shape: [1, 1, 512, 512] - axes: - - role: batch - - role: channel - - role: y - - role: x - data_type: float32 - data_range: [-.inf, .inf] - test_tensor: test_input.npy - sample_tensor: test_input.npy - preprocessing: # list of preprocessing steps - - name: zero_mean_unit_variance # name of preprocessing step - kwargs: - mode: per_sample # mode in [fixed, per_dataset, per_sample] - axes: yx # subset of axes to normalize jointly, batch ('b') is not a valid axis key here! - -outputs: -- name: probability - description: probability in [0,1] - axes: bcyx - data_type: float32 - data_range: [-.inf, .inf] - halo: [0, 0, 32, 32] - test_tensor: test_output.npy - sample_tensor: test_output.npy - shape: - reference_tensor: raw - scale: [1.0, 1.0, 1.0, 1.0] - offset: [0.0, 0.0, 0.0, 0.0] - -weights: - pytorch_state_dict: - authors: - - name: "Constantin Pape;@bioimage-io" - affiliation: "EMBL Heidelberg" - orcid: "0000-0001-6562-7187" - sha256: e4d3885bccbe41cbf6c1d825f3cd2b707c7021ead5593156007e407a16b27cf2 - source: https://zenodo.org/record/3446812/files/unet2d_weights.torch - architecture: unet2d.py:UNet2d - architecture_sha256: cf42a6d86adeb4eb6e8e37b539a20e5413866b183bed88f4e2e26ad1639761ed - kwargs: {input_channels: 1, output_channels: 1} - dependencies: conda:environment.yaml - onnx: - sha256: f1f086d5e340f9d4d7001a1b62a2b835f9b87a2fb5452c4fe7d8cc821bdf539c - source: weights.onnx - opset_version: 12 - parent: https://zenodo.org/record/3446812/files/unet2d_weights.torch - torchscript: - sha256: 62fa1c39923bee7d58a192277e0dd58f2da9ee810662addadd0f44a3784d9210 - source: weights.pt - parent: https://zenodo.org/record/3446812/files/unet2d_weights.torch - -type: model -version: 0.1.3 -download_url: https://example.com/ # note: not recommended for model RDFs - -training_data: - id: ilastik/covid_if_training_data # note: not the real training data diff --git a/example_use/load_model_and_create_your_own.ipynb b/example_use/load_model_and_create_your_own.ipynb index 3480a068d..aecae80bf 100644 --- a/example_use/load_model_and_create_your_own.ipynb +++ b/example_use/load_model_and_create_your_own.ipynb @@ -45,11 +45,13 @@ "else:\n", " raise NotImplementedError(example_model_id)\n", "\n", - "model = load_description(url, format_version=\"latest\")\n", - "if isinstance(model, InvalidDescr):\n", - " raise ValueError(f\"Failed to load {example_model_id}:\\n{model.validation_summary.format()}\")\n", - "elif not isinstance(model, ModelDescr):\n", + "loaded_descr = load_description(url, format_version=\"latest\")\n", + "if isinstance(loaded_descr, InvalidDescr):\n", + " raise ValueError(f\"Failed to load {example_model_id}:\\n{loaded_descr.validation_summary.format()}\")\n", + "elif not isinstance(loaded_descr, ModelDescr):\n", " raise ValueError(\"This notebook expects a model description\")\n", + "else:\n", + " model = loaded_descr\n", "\n", "print(f\"loaded '{model.name}'\")\n" ] @@ -264,12 +266,12 @@ "source": [ "output_axes = [\n", " BatchAxis(),\n", - " ChannelAxis(channel_names=[\"membrane\"])]\n", + " ChannelAxis(channel_names=[Identifier(\"membrane\")])]\n", "if example_model_id == \"impartial-shrimp\":\n", " output_axes += [\n", - " SpaceInputAxis(id=AxisId(\"z\"), size=ParameterizedSize(min=16, step=8)), # implicitly same size as raw.z as it is parametrized the same.\n", - " SpaceInputAxis(id=AxisId('y'), size=ParameterizedSize(min=144, step=72)),\n", - " SpaceInputAxis(id=AxisId('x'), size=ParameterizedSize(min=144, step=72))\n", + " SpaceOutputAxis(id=AxisId(\"z\"), size=ParameterizedSize(min=16, step=8)), # implicitly same size as raw.z as it is parametrized the same.\n", + " SpaceOutputAxis(id=AxisId('y'), size=ParameterizedSize(min=144, step=72)),\n", + " SpaceOutputAxis(id=AxisId('x'), size=ParameterizedSize(min=144, step=72))\n", " ]\n", "elif example_model_id == \"pioneering-rhino\":\n", " output_axes += [\n", @@ -320,12 +322,14 @@ "metadata": {}, "outputs": [], "source": [ + "from bioimageio.spec.model.v0_5 import LicenseId\n", + "\n", "my_model_descr = ModelDescr(\n", " name=\"My cool model\",\n", " description=\"A test model for demonstration purposes only\",\n", " authors=[Author(name=\"me\", affiliation=\"my institute\", github_user=\"bioimageiobot\")], # change github_user to your GitHub account name\n", " cite=[CiteEntry(text=\"for model training see my paper\", doi=Doi(\"10.1234something\"))],\n", - " license=\"MIT\",\n", + " license=LicenseId(\"MIT\"),\n", " documentation=HttpUrl(\"https://raw.githubusercontent.com/bioimage-io/spec-bioimage-io/main/README.md\"),\n", " git_repo=HttpUrl(\"https://github.com/bioimage-io/spec-bioimage-io\"), # change to repo where your model is developed\n", " inputs=[input_descr],\n", diff --git a/tests/test_example_specs.py b/tests/test_example_specs.py index f38a34ea5..02987854f 100644 --- a/tests/test_example_specs.py +++ b/tests/test_example_specs.py @@ -3,8 +3,6 @@ import pytest -from bioimageio.spec._description import DISCOVER, LATEST -from bioimageio.spec._internal.types import FormatVersionPlaceholder from tests.conftest import EXAMPLE_DESCRIPTIONS from tests.utils import ParameterSet, check_bioimageio_yaml @@ -48,18 +46,16 @@ def yield_invalid_descr_paths() -> Iterable[ParameterSet]: } -@pytest.mark.parametrize("format_version", [DISCOVER, LATEST]) @pytest.mark.parametrize("descr_path,key", list(yield_valid_descr_paths())) def test_example_descr_paths( descr_path: Path, key: str, - format_version: FormatVersionPlaceholder, bioimageio_json_schema: Mapping[Any, Any], ): check_bioimageio_yaml( descr_path, root=descr_path.parent, - as_latest=format_version == LATEST, + as_latest=False, exclude_fields_from_roundtrip=EXCLUDE_FIELDS_FROM_ROUNDTRIP.get(key, set()), bioimageio_json_schema=bioimageio_json_schema, )