Skip to content

Commit

Permalink
fix some typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FynnBe committed Jun 8, 2024
1 parent 0134584 commit d936a56
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
1 change: 0 additions & 1 deletion bioimageio/spec/partner_utils/imjoy/_plugin_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def enrich_partial_rdf_with_imjoy_plugin(
) -> Dict[str, Any]:
"""
a (partial) rdf may have 'rdf_source' or 'source' which resolve to rdf data that may be overwritten.
Due to resolving imjoy plugins this is not done in bioimageio.spec.collection atm
"""

enriched_rdf: Dict[str, Any] = {}
Expand Down
37 changes: 22 additions & 15 deletions example/load_model_and_create_your_own.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,17 @@
"from typing import Any\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from imageio.v3 import imread\n",
"import imageio.v3\n",
"from numpy.typing import NDArray\n",
"\n",
"from bioimageio.spec._internal.io import FileSource\n",
"from bioimageio.spec.utils import download\n",
"\n",
"def imread(src: FileSource) -> NDArray[Any]:\n",
" \"\"\"typed `imageio.v3.imread`\"\"\"\n",
" img: NDArray[Any] = imageio.v3.imread(download(src).path)\n",
" return img\n",
"\n",
"print(f\"The model is named '{model.name}'\")\n",
"print(f\"Description:\\n{model.description}\")\n",
"print(f\"License: {model.license}\")"
Expand Down Expand Up @@ -250,11 +256,11 @@
"for i, cover in enumerate(model.covers):\n",
" downloaded_cover = download(cover)\n",
" cover_data: NDArray[Any] = imread(downloaded_cover.path)\n",
" plt.figure(figsize=(10, 10))\n",
" plt.imshow(cover_data)\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
" plt.title(f\"cover image {downloaded_cover.original_file_name}\")\n",
" _ = plt.figure(figsize=(10, 10))\n",
" plt.imshow(cover_data) # type: ignore\n",
" plt.xticks([]) # type: ignore\n",
" plt.yticks([]) # type: ignore\n",
" plt.title(f\"cover image {downloaded_cover.original_file_name}\") # type: ignore\n",
" plt.show()"
]
},
Expand All @@ -276,7 +282,7 @@
" continue\n",
"\n",
" print(w.weights_format_name)\n",
" print(f\"weights are available at {w.source.absolute}\")\n",
" print(f\"weights are available at {w.source.absolute()}\")\n",
" print(f\"and have a SHA-256 value of {w.sha256}\")\n",
" details = {k: v for k, v in w.model_dump(mode=\"json\", exclude_none=True).items() if k not in (\"source\", \"sha256\")}\n",
" if details:\n",
Expand Down Expand Up @@ -304,9 +310,9 @@
" print(f\"\\ninput '{ipt.id}' with axes:\")\n",
" pprint(ipt.axes)\n",
" print(f\"Data description: {ipt.data}\")\n",
" print(f\"Test tensor available at: {ipt.test_tensor.source.absolute}\")\n",
" print(f\"Test tensor available at: {ipt.test_tensor.source.absolute()}\")\n",
" if len(ipt.preprocessing) > 1:\n",
" print(f\"This input is preprocessed with: \")\n",
" print(\"This input is preprocessed with: \")\n",
" for p in ipt.preprocessing:\n",
" print(p)\n",
"\n",
Expand All @@ -317,9 +323,9 @@
" print(f\"\\noutput '{out.id}' with axes:\")\n",
" pprint(out.axes)\n",
" print(f\"Data description: {out.data}\")\n",
" print(f\"Test tensor available at: {out.test_tensor.source.absolute}\")\n",
" print(f\"Test tensor available at: {out.test_tensor.source.absolute()}\")\n",
" if len(out.postprocessing) > 1:\n",
" print(f\"This output is postprocessed with: \")\n",
" print(\"This output is postprocessed with: \")\n",
" for p in out.postprocessing:\n",
" print(p)"
]
Expand Down Expand Up @@ -348,7 +354,7 @@
" arch = w.architecture\n",
" print(f\"callable: {arch.callable}\")\n",
" if isinstance(arch, ArchitectureFromFileDescr):\n",
" print(f\"import from file: {arch.source.absolute}\")\n",
" print(f\"import from file: {arch.source.absolute()}\")\n",
" if arch.sha256 is not None:\n",
" print(f\"SHA-256: {arch.sha256}\")\n",
" elif isinstance(arch, ArchitectureFromLibraryDescr):\n",
Expand Down Expand Up @@ -610,9 +616,10 @@
"outputs": [],
"source": [
"for cover in my_model_descr.covers:\n",
" plt.imshow(imread(cover))\n",
" plt.xticks([])\n",
" plt.yticks([])\n",
" img: NDArray[Any] = imread(download(cover).path)\n",
" _ = plt.imshow(img)\n",
" plt.xticks([]) # type: ignore\n",
" plt.yticks([]) # type: ignore\n",
" plt.show()"
]
},
Expand Down

0 comments on commit d936a56

Please sign in to comment.