Skip to content

Commit

Permalink
Merge pull request #555 from bioimage-io/patchy_stuff
Browse files Browse the repository at this point in the history
A few minor updates
  • Loading branch information
FynnBe authored Mar 13, 2024
2 parents 4fc3e74 + 02bcd06 commit d6f7b87
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bioimageio/spec/model/v0_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -1877,7 +1877,9 @@ def _validate_tensor_references_in_proc_kwargs(self, info: ValidationInfo) -> Se
]
"""A human-readable name of this model.
It should be no longer than 64 characters
and may only contain letter, number, underscore, minus or space characters."""
and may only contain letter, number, underscore, minus or space characters.
We recommend to chose a name that refers to the model's task and image modality.
"""

outputs: NotEmpty[Sequence[OutputTensorDescr]]
"""Describes the output tensors."""
Expand Down
39 changes: 36 additions & 3 deletions example_use/load_model_and_create_your_own.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"metadata": {},
"outputs": [],
"source": [
"assert model.validation_summary is not None\n",
"print(model.validation_summary.format())"
]
},
Expand Down Expand Up @@ -297,7 +296,11 @@
"metadata": {},
"outputs": [],
"source": [
"from bioimageio.spec.model.v0_5 import ArchitectureFromFileDescr, Version\n",
"from bioimageio.spec.model.v0_5 import (\n",
" ArchitectureFromFileDescr,\n",
" ArchitectureFromLibraryDescr,\n",
" Version,\n",
")\n",
"\n",
"try:\n",
" import torch\n",
Expand All @@ -306,7 +309,15 @@
"else:\n",
" pytorch_version = Version(torch.__version__)\n",
"\n",
"pytorch_architecture = ArchitectureFromFileDescr(source=arch_file_path, sha256=arch_file_sha256, callable=arch_name, kwargs=arch_kwargs)\n"
"pytorch_architecture = ArchitectureFromFileDescr(\n",
" source=arch_file_path,\n",
" sha256=arch_file_sha256,\n",
" callable=arch_name,\n",
" kwargs=arch_kwargs\n",
")\n",
"# A model architecture published as a package may also be referenced\n",
"# Make sure to include the library referenced in `import_from` in the `depdendencies`\n",
"my_unused_arch = ArchitectureFromLibraryDescr(callable=Identifier(\"MyModel\"), import_from=\"my_library.subpackage\")\n"
]
},
{
Expand Down Expand Up @@ -406,6 +417,28 @@
"assert summary == my_model_descr.validation_summary"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Package your model\n",
"\n",
"A model is more than it's YAML description file! We refer to a zip-file containing all files relevant to a model as a model package. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pathlib import Path\n",
"\n",
"from bioimageio.spec import save_bioimageio_package\n",
"\n",
"print(\"package path:\", save_bioimageio_package(my_model_descr, output_path=Path('my_model.zip')))"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down

0 comments on commit d6f7b87

Please sign in to comment.