|
95 | 95 | "# Improve readiblity of validation errors\n",
|
96 | 96 | "enable_pretty_validation_errors_in_ipynb()\n",
|
97 | 97 | "\n",
|
| 98 | + "\n", |
98 | 99 | "# Function to display input and prediction output images\n",
|
99 |
| - "def show_images(images: Union[Mapping[str, NDArray[Any]], Mapping[TensorId, Union[Tensor, NDArray[Any]]]]) -> None:\n", |
| 100 | + "def show_images(\n", |
| 101 | + " images: Union[\n", |
| 102 | + " Mapping[str, NDArray[Any]], Mapping[TensorId, Union[Tensor, NDArray[Any]]]\n", |
| 103 | + " ],\n", |
| 104 | + ") -> None:\n", |
100 | 105 | "\n",
|
101 | 106 | " for title, image in images.items():\n",
|
102 | 107 | " if isinstance(image, Tensor):\n",
|
|
162 | 167 | "outputs": [],
|
163 | 168 | "source": [
|
164 | 169 | "model_source = \"affable-shark/1.2\"\n",
|
165 |
| - "#model_source = \"10.5281/zenodo.6287342\"\n", |
166 |
| - "#model_source = \"https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/draft/files/rdf.yaml\"" |
| 170 | + "# model_source = \"10.5281/zenodo.6287342\"\n", |
| 171 | + "# model_source = \"https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/draft/files/rdf.yaml\"" |
167 | 172 | ]
|
168 | 173 | },
|
169 | 174 | {
|
|
220 | 225 | "from bioimageio.core import test_model\n",
|
221 | 226 | "\n",
|
222 | 227 | "model = load_model_description(model_source, format_version=\"latest\")\n",
|
223 |
| - "test_summary = test_model(model) #Test model to check environment compatibility \n", |
224 |
| - "assert test_summary.status == \"passed\", test_summary.display() " |
| 228 | + "test_summary = test_model(model) # Test model to check environment compatibility\n", |
| 229 | + "assert test_summary.status == \"passed\", test_summary.display()" |
225 | 230 | ]
|
226 | 231 | },
|
227 | 232 | {
|
|
345 | 350 | }
|
346 | 351 | ],
|
347 | 352 | "source": [
|
348 |
| - "\n", |
349 | 353 | "print(\n",
|
350 | 354 | " f\"Model '{model.name}' requires {len(model.inputs)} input(s) with the following features:\"\n",
|
351 | 355 | ")\n",
|
|
422 | 426 | "prediction: Sample = predict(model=model, inputs=input)\n",
|
423 | 427 | "\n",
|
424 | 428 | "# show the input and prediction result\n",
|
425 |
| - "show_images(input | prediction.members)\n" |
| 429 | + "show_images(input | prediction.members)" |
426 | 430 | ]
|
427 | 431 | },
|
428 | 432 | {
|
|
484 | 488 | "from bioimageio.core.stat_measures import DatasetMean\n",
|
485 | 489 | "\n",
|
486 | 490 | "sample = Sample(\n",
|
487 |
| - " members={\"raw\": test_input_tensor}, \n", |
488 |
| - " stat={DatasetMean(member_id=TensorId(\"raw\")): 123.456}, # Example mean value\n", |
489 |
| - " id=\"sample-from-numpy\"\n", |
| 491 | + " members={\"raw\": test_input_tensor},\n", |
| 492 | + " stat={DatasetMean(member_id=TensorId(\"raw\")): 123.456}, # Example mean value\n", |
| 493 | + " id=\"sample-from-numpy\",\n", |
490 | 494 | ")\n",
|
491 | 495 | "\n",
|
492 | 496 | "sample"
|
|
0 commit comments