Skip to content

Commit 04a408f

Browse files
committed
docs: update example notebooks
1 parent d28edb3 commit 04a408f

8 files changed

+1284
-4434
lines changed

examples/pannuke_cellpose_benchmark.ipynb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"outputs": [],
3737
"source": [
3838
"from cellseg_models_pytorch.models import get_model\n",
39-
"from cellseg_models_pytorch.inference import SlidingWindowInferer, ResizeInferer\n",
39+
"from cellseg_models_pytorch.inference import ResizeInferer\n",
4040
"\n",
4141
"# the pannuke classes\n",
4242
"type_classes = {\n",
@@ -50,12 +50,12 @@
5050
"\n",
5151
"# Initializee the model and input and ckpt paths\n",
5252
"model = get_model(\"cellpose\", type=\"base\", ntypes=len(type_classes))\n",
53-
"input_images = \"/path/to/pannuke/fold1/images/\" # modify this path\n",
54-
"ckpt_path = \"/path/to/fold23_weights.ckpt\" # modify this path\n",
53+
"input_images = \"/path/to/pannuke/fold1/images/\" # modify this path\n",
54+
"ckpt_path = \"/path/to/fold23_weights.ckpt\" # modify this path\n",
5555
"\n",
5656
"# Initialize the output head args\n",
57-
"out_activations={\"type\": \"softmax\", \"cellpose\": None}\n",
58-
"out_boundary_weights={\"type\": False, \"cellpose\": False}\n",
57+
"out_activations = {\"type\": \"softmax\", \"cellpose\": None}\n",
58+
"out_boundary_weights = {\"type\": False, \"cellpose\": False}\n",
5959
"\n",
6060
"# Initialize the inferer\n",
6161
"inferer = ResizeInferer(\n",
@@ -64,9 +64,9 @@
6464
" checkpoint_path=ckpt_path,\n",
6565
" out_activations=out_activations,\n",
6666
" out_boundary_weights=out_boundary_weights,\n",
67-
" resize=(256, 256), # not actually resizing anything\n",
67+
" resize=(256, 256), # not actually resizing anything\n",
6868
" instance_postproc=\"cellpose\",\n",
69-
" normalization=\"minmax\", # minmax normalization was used for training\n",
69+
" normalization=\"minmax\", # minmax normalization was used for training\n",
7070
")"
7171
]
7272
},
@@ -85,7 +85,9 @@
8585
],
8686
"source": [
8787
"# Run the inference\n",
88-
"inferer.infer(save_intermediate=True) # save_intermediate needs to be set to True for latency benchmarks."
88+
"inferer.infer(\n",
89+
" save_intermediate=True\n",
90+
") # save_intermediate needs to be set to True for latency benchmarks."
8991
]
9092
},
9193
{
@@ -184,7 +186,7 @@
184186
"source": [
185187
"from cellseg_models_pytorch.utils.seg_benchmark import SegBenchmarker\n",
186188
"\n",
187-
"in_dir = \"/path/to/pannuke/fold1/labels\" # modify this path\n",
189+
"in_dir = \"/path/to/pannuke/fold1/labels\" # modify this path\n",
188190
"bm = SegBenchmarker(\n",
189191
" true_path=in_dir,\n",
190192
" inferer=inferer,\n",
@@ -424,7 +426,7 @@
424426
}
425427
],
426428
"source": [
427-
"# If we filter out also the examples that got \n",
429+
"# If we filter out also the examples that got\n",
428430
"res_df[res_df[[\"pq\", \"dq\", \"sq\"]] > 0].mean(axis=0)"
429431
]
430432
},
@@ -524,7 +526,7 @@
524526
}
525527
],
526528
"source": [
527-
"res_df.loc[res_df['pq'] >= 0].groupby(\"type\").mean(numeric_only=True)"
529+
"res_df.loc[res_df[\"pq\"] >= 0].groupby(\"type\").mean(numeric_only=True)"
528530
]
529531
},
530532
{

examples/pannuke_nuclei_segmentation_cellpose.ipynb

Lines changed: 205 additions & 180 deletions
Large diffs are not rendered by default.

examples/pannuke_nuclei_segmentation_cellpose_dinov2.ipynb

Lines changed: 130 additions & 252 deletions
Large diffs are not rendered by default.

examples/pannuke_nuclei_segmentation_cellvit.ipynb

Lines changed: 164 additions & 303 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)