Skip to content

Commit

Permalink
fix: modify example notebooks inference
Browse files Browse the repository at this point in the history
  • Loading branch information
okunator committed Oct 10, 2023
1 parent 351c232 commit 40a9865
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 431 deletions.
2 changes: 2 additions & 0 deletions changelog.d/20230922_082631_oskari.lehtonen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Features
- Add option for mixed precision inference
5 changes: 5 additions & 0 deletions changelog.d/20231010_143903_oskari.lehtonen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Features
- Add support for `.geojson`, `.feather`, `.parquet` file formats when running inference.

## Style
- Update the `Ìnferer.infer()` -method api to accept arguments related to saving the model outputs.
414 changes: 0 additions & 414 deletions examples/lizard_nuclei_segmentation_cellpose.ipynb

This file was deleted.

5 changes: 2 additions & 3 deletions examples/pannuke_cellpose_benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
" resize=(256, 256), # not actually resizing anything\n",
" instance_postproc=\"cellpose\",\n",
" normalization=\"minmax\", # minmax normalization was used for training\n",
" save_intermediate=True # this needs to be set to True for latency benchmarks.\n",
")"
]
},
Expand All @@ -86,7 +85,7 @@
],
"source": [
"# Run the inference\n",
"inferer.infer()"
"inferer.infer(save_intermediate=True) # save_intermediate needs to be set to True for latency benchmarks."
]
},
{
Expand Down Expand Up @@ -1330,7 +1329,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12 (main, Apr 5 2022, 06:56:58) \n[GCC 7.5.0]"
"version": "3.9.12"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_cellpose.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,6 @@
" out_boundary_weights={\"cellpose\": False, \"type\": False},\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"cellpose\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder\n",
" normalization=\"minmax\",\n",
Expand Down Expand Up @@ -955,7 +954,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_cellpose_dinov2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,6 @@
" out_boundary_weights={\"cellpose\": False, \"type\": False},\n",
" resize=(252, 252), # resize the input images to a multiple of 14,\n",
" instance_postproc=\"cellpose\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder\n",
" normalization=\"percentile\",\n",
Expand Down Expand Up @@ -951,7 +950,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_cellvit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,6 @@
" out_boundary_weights={\"hovernet\": False, \"inst\": False, \"type\": False},\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"hovernet\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder\n",
" normalization=\"minmax\",\n",
Expand Down Expand Up @@ -960,7 +959,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_cppnet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,6 @@
" out_boundary_weights=out_weights,\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"stardist\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder,\n",
" normalization=\"percentile\"\n",
Expand Down Expand Up @@ -1048,7 +1047,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_hovernet.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2725,7 +2725,6 @@
" out_boundary_weights={\"hovernet\": False, \"inst\": False, \"type\": False},\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"hovernet\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder\n",
" normalization=\"minmax\",\n",
Expand Down Expand Up @@ -2781,7 +2780,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_omnipose.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,6 @@
" out_boundary_weights={\"omnipose\": False, \"type\": False},\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"omnipose\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50, # Use only the 50 first images of the folder\n",
" normalization=\"percentile\",\n",
Expand Down Expand Up @@ -809,7 +808,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down
2 changes: 0 additions & 2 deletions examples/pannuke_nuclei_segmentation_stardist.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,6 @@
" out_boundary_weights={\"dist\": False, \"stardist\": False, \"type\": False},\n",
" resize=(256, 256), # Not actually resizing anything,\n",
" instance_postproc=\"stardist\",\n",
" save_intermediate=True, # save intermediate soft masks for visualization\n",
" batch_size=8,\n",
" n_images=50 # Use only the 50 first images of the folder\n",
")\n",
Expand Down Expand Up @@ -2183,7 +2182,6 @@
"samples = list(inferer.out_masks.keys())\n",
"for i, ix in enumerate(ixs):\n",
" masks = inferer.out_masks[samples[ix]]\n",
" inter = inferer.soft_masks[samples[ix]]\n",
"\n",
" img_path = save_dir / \"valid\" / f\"images/{samples[ix]}.png\"\n",
" img = FileHandler.read_img(img_path)\n",
Expand Down

0 comments on commit 40a9865

Please sign in to comment.