|
3 | 3 | { |
4 | 4 | "cell_type": "markdown", |
5 | 5 | "metadata": { |
6 | | - "colab_type": "text", |
7 | | - "id": "view-in-github" |
| 6 | + "id": "view-in-github", |
| 7 | + "colab_type": "text" |
8 | 8 | }, |
9 | 9 | "source": [ |
10 | | - "<a href=\"https://colab.research.google.com/github/AdaptiveMotorControlLab/CellSeg3d/blob/main/notebooks/colab_inference_demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
| 10 | + "<a href=\"https://colab.research.google.com/github/AdaptiveMotorControlLab/CellSeg3d/blob/main/notebooks/Colab_inference_demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
11 | 11 | ] |
12 | 12 | }, |
13 | 13 | { |
14 | 14 | "cell_type": "markdown", |
15 | | - "metadata": {}, |
| 15 | + "metadata": { |
| 16 | + "id": "PoYFnmmQAm-x" |
| 17 | + }, |
16 | 18 | "source": [ |
17 | 19 | "# **CellSeg3D : inference demo notebook**\n", |
18 | 20 | "\n", |
19 | 21 | "---\n", |
20 | 22 | "This notebook is part of the [CellSeg3D project](https://github.com/AdaptiveMotorControlLab/CellSeg3d) in the [Mathis Lab of Adaptive Intelligence](https://www.mackenziemathislab.org/).\n", |
21 | 23 | "\n", |
22 | | - "- 💜 The foundation of this notebook owes much to the **[ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic)** project and to the **[DeepLabCut](https://github.com/DeepLabCut/DeepLabCut)** team for bringing Colab into scientific open software." |
| 24 | + "- 💜 The foundation of this notebook owes much to the **[ZeroCostDL4Mic](https://github.com/HenriquesLab/ZeroCostDL4Mic)** project and to the **[DeepLabCut](https://github.com/DeepLabCut/DeepLabCut)** team." |
23 | 25 | ] |
24 | 26 | }, |
25 | 27 | { |
26 | 28 | "cell_type": "markdown", |
27 | | - "metadata": {}, |
| 29 | + "metadata": { |
| 30 | + "id": "vJLmPrWhAm-z" |
| 31 | + }, |
28 | 32 | "source": [ |
29 | 33 | "# **1. Installing dependencies**\n", |
30 | 34 | "---" |
31 | 35 | ] |
32 | 36 | }, |
33 | 37 | { |
34 | 38 | "cell_type": "markdown", |
35 | | - "metadata": {}, |
| 39 | + "metadata": { |
| 40 | + "id": "CUNTOWCnAm-z" |
| 41 | + }, |
36 | 42 | "source": [ |
37 | 43 | "## **1.1 Installing CellSeg3D**\n", |
38 | 44 | "---" |
|
41 | 47 | { |
42 | 48 | "cell_type": "code", |
43 | 49 | "execution_count": null, |
44 | | - "metadata": {}, |
| 50 | + "metadata": { |
| 51 | + "id": "bnFKu6uFAm-z" |
| 52 | + }, |
45 | 53 | "outputs": [], |
46 | 54 | "source": [ |
47 | 55 | "#@markdown ##Install CellSeg3D and dependencies\n", |
|
51 | 59 | }, |
52 | 60 | { |
53 | 61 | "cell_type": "markdown", |
54 | | - "metadata": {}, |
| 62 | + "metadata": { |
| 63 | + "id": "SfYAv60MAm-z" |
| 64 | + }, |
55 | 65 | "source": [ |
56 | 66 | "## **1.2. Restart your runtime**\n", |
57 | 67 | "---\n", |
|
66 | 76 | { |
67 | 77 | "cell_type": "code", |
68 | 78 | "execution_count": null, |
69 | | - "metadata": {}, |
| 79 | + "metadata": { |
| 80 | + "id": "Of85zlxzAm-z" |
| 81 | + }, |
70 | 82 | "outputs": [], |
71 | 83 | "source": [ |
72 | 84 | "# @title Force session restart\n", |
|
75 | 87 | }, |
76 | 88 | { |
77 | 89 | "cell_type": "markdown", |
78 | | - "metadata": {}, |
| 90 | + "metadata": { |
| 91 | + "id": "pSVZsebrAm-0" |
| 92 | + }, |
79 | 93 | "source": [ |
80 | 94 | "## **1.3 Load key dependencies**\n", |
81 | 95 | "---" |
|
84 | 98 | { |
85 | 99 | "cell_type": "code", |
86 | 100 | "execution_count": null, |
87 | | - "metadata": {}, |
| 101 | + "metadata": { |
| 102 | + "id": "vzm75tE_Am-0" |
| 103 | + }, |
88 | 104 | "outputs": [], |
89 | 105 | "source": [ |
90 | 106 | "# @title Load libraries\n", |
|
99 | 115 | }, |
100 | 116 | { |
101 | 117 | "cell_type": "markdown", |
102 | | - "metadata": {}, |
| 118 | + "metadata": { |
| 119 | + "id": "XLEJsiVNAm-0" |
| 120 | + }, |
103 | 121 | "source": [ |
104 | 122 | "# **2. Inference**\n", |
105 | 123 | "---" |
106 | 124 | ] |
107 | 125 | }, |
108 | 126 | { |
109 | 127 | "cell_type": "markdown", |
110 | | - "metadata": {}, |
| 128 | + "metadata": { |
| 129 | + "id": "gjp4WL40Am-0" |
| 130 | + }, |
111 | 131 | "source": [ |
112 | 132 | "\n", |
113 | 133 | "## **2.1. Check for GPU access**\n", |
|
125 | 145 | { |
126 | 146 | "cell_type": "code", |
127 | 147 | "execution_count": null, |
128 | | - "metadata": {}, |
| 148 | + "metadata": { |
| 149 | + "id": "Fe8hNkOpAm-0" |
| 150 | + }, |
129 | 151 | "outputs": [], |
130 | 152 | "source": [ |
131 | 153 | "#@markdown This cell verifies if GPU access is available.\n", |
|
144 | 166 | }, |
145 | 167 | { |
146 | 168 | "cell_type": "markdown", |
147 | | - "metadata": {}, |
| 169 | + "metadata": { |
| 170 | + "id": "JBCyJAGsAm-0" |
| 171 | + }, |
148 | 172 | "source": [ |
149 | 173 | "## **2.2 Run inference**\n", |
150 | 174 | "---" |
|
153 | 177 | { |
154 | 178 | "cell_type": "code", |
155 | 179 | "execution_count": null, |
156 | | - "metadata": {}, |
| 180 | + "metadata": { |
| 181 | + "id": "O0jLRpARAm-0" |
| 182 | + }, |
157 | 183 | "outputs": [], |
158 | 184 | "source": [ |
159 | | - "# @title Load demo image and inference configuration\n", |
160 | | - "#@markdown This cell loads a demo image and load the inference configuration.\n", |
161 | | - "demo_image_path = \"./CellSeg3D/examples/c5image.tif\n", |
| 185 | + "demo_image_path = \"/content/CellSeg3D/examples/c5image.tif\"\n", |
162 | 186 | "demo_image = imread(demo_image_path)\n", |
163 | 187 | "inference_config = cs3d.CONFIG\n", |
164 | 188 | "post_process_config = cs3d.PostProcessConfig()\n", |
|
170 | 194 | { |
171 | 195 | "cell_type": "code", |
172 | 196 | "execution_count": null, |
173 | | - "metadata": {}, |
| 197 | + "metadata": { |
| 198 | + "id": "hIEKoyEGAm-0" |
| 199 | + }, |
174 | 200 | "outputs": [], |
175 | 201 | "source": [ |
176 | | - "# @title Run inference on demo image\n", |
177 | | - "#@markdown This cell runs the inference on the demo image.\n", |
178 | 202 | "result = cs3d.inference_on_images(\n", |
179 | 203 | " demo_image,\n", |
180 | 204 | " config=inference_config,\n", |
|
184 | 208 | { |
185 | 209 | "cell_type": "code", |
186 | 210 | "execution_count": null, |
187 | | - "metadata": {}, |
| 211 | + "metadata": { |
| 212 | + "id": "IFbmZ3_zAm-1" |
| 213 | + }, |
188 | 214 | "outputs": [], |
189 | 215 | "source": [ |
190 | 216 | "# @title Post-process the result\n", |
|
198 | 224 | { |
199 | 225 | "cell_type": "code", |
200 | 226 | "execution_count": null, |
201 | | - "metadata": {}, |
| 227 | + "metadata": { |
| 228 | + "id": "TMRiQ-m4Am-1" |
| 229 | + }, |
202 | 230 | "outputs": [], |
203 | 231 | "source": [ |
204 | 232 | "# @title Display the result\n", |
205 | 233 | "#@markdown This cell displays the result of the inference and post-processing. Use the slider to navigate through the z-stack.\n", |
206 | | - "# @markdown *KNOWN ISSUE* : The colormap of the labels is not consistent between the z-stacks. \n", |
| 234 | + "# @markdown *KNOWN ISSUE* : The colormap of the labels is not consistent between the z-stacks.\n", |
207 | 235 | "import matplotlib.pyplot as plt\n", |
208 | 236 | "import ipywidgets as widgets\n", |
209 | 237 | "from IPython.display import display\n", |
|
242 | 270 | { |
243 | 271 | "cell_type": "code", |
244 | 272 | "execution_count": null, |
245 | | - "metadata": {}, |
| 273 | + "metadata": { |
| 274 | + "id": "Tw5exJ5EAm-1" |
| 275 | + }, |
246 | 276 | "outputs": [], |
247 | 277 | "source": [ |
248 | 278 | "# @title Display the statistics\n", |
|
255 | 285 | { |
256 | 286 | "cell_type": "code", |
257 | 287 | "execution_count": null, |
258 | | - "metadata": {}, |
| 288 | + "metadata": { |
| 289 | + "id": "0NhZ-YksAm-1" |
| 290 | + }, |
259 | 291 | "outputs": [], |
260 | 292 | "source": [ |
261 | 293 | "# @title Plot the a 3D view, with statistics\n", |
|
295 | 327 | " )\n", |
296 | 328 | "\n", |
297 | 329 | " fig.show(renderer=\"colab\")\n", |
298 | | - " \n", |
| 330 | + "\n", |
299 | 331 | "plotly_cells_stats(data)" |
300 | 332 | ] |
301 | 333 | } |
|
304 | 336 | "accelerator": "GPU", |
305 | 337 | "colab": { |
306 | 338 | "gpuType": "T4", |
307 | | - "include_colab_link": true, |
308 | | - "provenance": [] |
| 339 | + "provenance": [], |
| 340 | + "include_colab_link": true |
309 | 341 | }, |
310 | 342 | "kernelspec": { |
311 | 343 | "display_name": "Python 3", |
|
0 commit comments