|
39 | 39 | "\n", |
40 | 40 | "from numpy.typing import NDArray\n", |
41 | 41 | "\n", |
| 42 | + "\n", |
42 | 43 | "def show_images(images: Dict[str, Union[Tensor, NDArray[Any], Path]]):\n", |
43 | 44 | " v = napari.Viewer()\n", |
44 | 45 | " for name, im in images.items():\n", |
|
194 | 195 | "input_paths = {ipt.id: download(ipt.test_tensor).path for ipt in model.inputs}\n", |
195 | 196 | "print(f\"input paths: {input_paths}\")\n", |
196 | 197 | "assert isinstance(model, v0_5.ModelDescr)\n", |
197 | | - "sample = create_sample_for_model(model=model, inputs=input_paths, sample_id=\"my_demo_sample\")\n", |
| 198 | + "sample = create_sample_for_model(\n", |
| 199 | + " model=model, inputs=input_paths, sample_id=\"my_demo_sample\"\n", |
| 200 | + ")\n", |
198 | 201 | "sample" |
199 | 202 | ] |
200 | 203 | }, |
|
268 | 271 | "metadata": {}, |
269 | 272 | "outputs": [], |
270 | 273 | "source": [ |
271 | | - "from bioimageio.core import predict#, predict_many\n", |
| 274 | + "from bioimageio.core import predict # , predict_many\n", |
272 | 275 | "\n", |
273 | 276 | "predict(model=model, inputs=sample)\n", |
274 | 277 | "# predict_many(model=model, inputs=[sample])" |
|
295 | 298 | "# Do demonstrate this we load the sample image.\n", |
296 | 299 | "from pprint import pprint\n", |
297 | 300 | "\n", |
298 | | - "large_input_sample = create_sample_for_model(model=model, inputs={ipt.id: ipt.sample_tensor.download().path for ipt in model.inputs}, sample_id=\"sample input\")\n", |
| 301 | + "large_input_sample = create_sample_for_model(\n", |
| 302 | + " model=model,\n", |
| 303 | + " inputs={ipt.id: ipt.sample_tensor.download().path for ipt in model.inputs},\n", |
| 304 | + " sample_id=\"sample input\",\n", |
| 305 | + ")\n", |
299 | 306 | "pprint({m: t.tagged_shape for m, t in large_input_sample.members.items()})" |
300 | 307 | ] |
301 | 308 | }, |
|
319 | 326 | "outputs": [], |
320 | 327 | "source": [ |
321 | 328 | "# Instead, we can use the method `predict_sample_with_blocking`, which will block/pad the image to a shape that fits the model.\n", |
322 | | - "large_output_sample = prediction_pipeline.predict_sample_with_blocking(large_input_sample)\n", |
| 329 | + "large_output_sample = prediction_pipeline.predict_sample_with_blocking(\n", |
| 330 | + " large_input_sample\n", |
| 331 | + ")\n", |
323 | 332 | "\n", |
324 | 333 | "# show the prediction result\n", |
325 | | - "show_images(\n", |
326 | | - " {**large_input_sample.members, **large_output_sample.members}\n", |
327 | | - ")" |
| 334 | + "show_images({**large_input_sample.members, **large_output_sample.members})" |
328 | 335 | ] |
329 | 336 | } |
330 | 337 | ], |
|
0 commit comments