|
36 | 36 | "outputs": [],
|
37 | 37 | "source": [
|
38 | 38 | "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", |
40 | 40 | "\n",
|
41 | 41 | "# the pannuke classes\n",
|
42 | 42 | "type_classes = {\n",
|
|
50 | 50 | "\n",
|
51 | 51 | "# Initializee the model and input and ckpt paths\n",
|
52 | 52 | "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", |
55 | 55 | "\n",
|
56 | 56 | "# 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", |
59 | 59 | "\n",
|
60 | 60 | "# Initialize the inferer\n",
|
61 | 61 | "inferer = ResizeInferer(\n",
|
|
64 | 64 | " checkpoint_path=ckpt_path,\n",
|
65 | 65 | " out_activations=out_activations,\n",
|
66 | 66 | " 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", |
68 | 68 | " instance_postproc=\"cellpose\",\n",
|
69 |
| - " normalization=\"minmax\", # minmax normalization was used for training\n", |
| 69 | + " normalization=\"minmax\", # minmax normalization was used for training\n", |
70 | 70 | ")"
|
71 | 71 | ]
|
72 | 72 | },
|
|
85 | 85 | ],
|
86 | 86 | "source": [
|
87 | 87 | "# 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." |
89 | 91 | ]
|
90 | 92 | },
|
91 | 93 | {
|
|
184 | 186 | "source": [
|
185 | 187 | "from cellseg_models_pytorch.utils.seg_benchmark import SegBenchmarker\n",
|
186 | 188 | "\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", |
188 | 190 | "bm = SegBenchmarker(\n",
|
189 | 191 | " true_path=in_dir,\n",
|
190 | 192 | " inferer=inferer,\n",
|
|
424 | 426 | }
|
425 | 427 | ],
|
426 | 428 | "source": [
|
427 |
| - "# If we filter out also the examples that got \n", |
| 429 | + "# If we filter out also the examples that got\n", |
428 | 430 | "res_df[res_df[[\"pq\", \"dq\", \"sq\"]] > 0].mean(axis=0)"
|
429 | 431 | ]
|
430 | 432 | },
|
|
524 | 526 | }
|
525 | 527 | ],
|
526 | 528 | "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)" |
528 | 530 | ]
|
529 | 531 | },
|
530 | 532 | {
|
|
0 commit comments