Skip to content

Commit 033130a

Browse files
committed
black
1 parent d41f4b8 commit 033130a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

example/model_usage.ipynb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"\n",
4040
"from numpy.typing import NDArray\n",
4141
"\n",
42+
"\n",
4243
"def show_images(images: Dict[str, Union[Tensor, NDArray[Any], Path]]):\n",
4344
" v = napari.Viewer()\n",
4445
" for name, im in images.items():\n",
@@ -194,7 +195,9 @@
194195
"input_paths = {ipt.id: download(ipt.test_tensor).path for ipt in model.inputs}\n",
195196
"print(f\"input paths: {input_paths}\")\n",
196197
"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",
198201
"sample"
199202
]
200203
},
@@ -268,7 +271,7 @@
268271
"metadata": {},
269272
"outputs": [],
270273
"source": [
271-
"from bioimageio.core import predict#, predict_many\n",
274+
"from bioimageio.core import predict # , predict_many\n",
272275
"\n",
273276
"predict(model=model, inputs=sample)\n",
274277
"# predict_many(model=model, inputs=[sample])"
@@ -295,7 +298,11 @@
295298
"# Do demonstrate this we load the sample image.\n",
296299
"from pprint import pprint\n",
297300
"\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",
299306
"pprint({m: t.tagged_shape for m, t in large_input_sample.members.items()})"
300307
]
301308
},
@@ -319,12 +326,12 @@
319326
"outputs": [],
320327
"source": [
321328
"# 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",
323332
"\n",
324333
"# 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})"
328335
]
329336
}
330337
],

0 commit comments

Comments
 (0)