Skip to content
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 89 additions & 4 deletions notebooks/Colab_inference_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"id": "view-in-github"
},
"source": [
"<a href=\"https://colab.research.google.com/github/MMathisLab/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>"
"<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>"
Comment thread
C-Achard marked this conversation as resolved.
Outdated
]
},
{
Expand Down Expand Up @@ -53,9 +53,94 @@
},
"outputs": [],
"source": [
"# @markdown ##Install CellSeg3D and grab demo data\n",
"!git clone https://github.com/AdaptiveMotorControlLab/CellSeg3d.git --branch main --single-branch ./CellSeg3D\n",
"!pip install napari-cellseg3d"
"# @markdown ## Install CellSeg3D only if needed\n",
"\n",
"import os\n",
"import shutil\n",
"import subprocess\n",
"import sys\n",
"from pathlib import Path\n",
"\n",
"\n",
"def run(cmd, **kwargs):\n",
" print(\"+\", \" \".join(cmd))\n",
" subprocess.check_call(cmd, **kwargs)\n",
"\n",
"\n",
"def cellseg3d_ok():\n",
" try:\n",
" import napari_cellseg3d\n",
" from napari_cellseg3d.dev_scripts import remote_inference\n",
"\n",
" print(\"CellSeg3D import OK.\")\n",
" return True\n",
"\n",
" except Exception as e:\n",
" print(\"CellSeg3D import failed:\")\n",
" print(type(e).__name__, e)\n",
" return False\n",
"\n",
"\n",
"if not cellseg3d_ok():\n",
" print(\"Installing CellSeg3D...\")\n",
"\n",
" if shutil.which(\"uv\") is None:\n",
" run([sys.executable, \"-m\", \"pip\", \"install\", \"-q\", \"uv\"])\n",
" else:\n",
" print(\"uv already installed.\")\n",
"\n",
" if not Path(\"CellSeg3D\").is_dir():\n",
" run(\n",
" [\n",
" \"git\",\n",
" \"clone\",\n",
Comment thread
C-Achard marked this conversation as resolved.
Outdated
" \"https://github.com/AdaptiveMotorControlLab/CellSeg3D.git\",\n",
" \"--branch\",\n",
" \"main\",\n",
" \"--single-branch\",\n",
" \"./CellSeg3D\",\n",
" ]\n",
" )\n",
" else:\n",
" print(\"CellSeg3D repo already cloned.\")\n",
"\n",
" run(\n",
" [\n",
" \"uv\",\n",
" \"pip\",\n",
" \"install\",\n",
" \"--system\",\n",
" \"napari-cellseg3d\",\n",
" ]\n",
" )\n",
"\n",
" print(\"Restarting runtime to reload installed binary dependencies...\")\n",
" print(\n",
" \"This will be shown as a crash, but this is expected. Please simply run the notebook again from the beginning after the runtime restarts.\"\n",
" )\n",
"\n",
" os.kill(os.getpid(), 9)\n",
"\n",
"else:\n",
" print(\"CellSeg3D already available — skipping install and restart.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"<div style=\"\n",
" padding: 12px 16px;\n",
" border-left: 5px solid #f59e0b;\n",
" border-radius: 6px;\n",
" margin: 12px 0;\n",
"\">\n",
" <b>⚠️ Runtime restart is required after installation</b><br>\n",
"The runtime must be restarted after installing CellSeg3D to use the newly installed package. \n",
"\n",
"<b>The notebook will \"crash\" after installing, but this is expected, you may simply run the notebook again from the beginning after the runtime restarts.</b>\n",
"</div>"
]
},
{
Expand Down
Loading