Skip to content

Commit

Permalink
Update links in notebooks and minor fixes (computational-cell-analyti…
Browse files Browse the repository at this point in the history
  • Loading branch information
anwai98 authored May 8, 2024
1 parent e0a3685 commit 4b2187a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 39 deletions.
49 changes: 28 additions & 21 deletions notebooks/automatic_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Automatic Instance Segmentation with Segment Anything for Microscopy\n",
"\n",
"This notebook shows how to use Segment Anything (SAM) for automatic instance segmentation, using the corresdponding functionality from `µsam` (Segment Anything for Microscopy). We use immunoflourescence microscopy images, abbreviated as `Covid IF` (from [Pape et al](https://doi.org/10.1002/bies.202000257)), in this notebook, but the functionality shown here should work for your (microscopy) images too!\n",
"This notebook shows how to use Segment Anything (SAM) for automatic instance segmentation, using the corresponding functionality from `µsam` (Segment Anything for Microscopy). We use immunoflourescence microscopy images, abbreviated as `Covid IF` (from [Pape et al](https://doi.org/10.1002/bies.202000257)), in this notebook. The functionalities shown here should work for your (microscopy) images too!\n",
"\n",
"We demonstrate using two different functionalities:\n",
"1. Automatic Mask Generation (AMG): The \"Segment Anything\" feature where positive point prompts are sampled in a grid over the entire image to perform instance segmentation.\n",
Expand Down Expand Up @@ -44,27 +44,24 @@
"current_spot = os.getcwd()\n",
"\n",
"if current_spot.startswith(\"/kaggle/working\"):\n",
" using_kaggle = True\n",
" print(\"Kaggle says hi!\")\n",
" root_dir = \"/kaggle/working\"\n",
"\n",
"elif current_spot.startswith(\"/content\"):\n",
" print(\"Google Colab says hi!\")\n",
" print(\" NOTE: The scripts have not been tested on Google Colab, you might need to adapt the installations a bit.\")\n",
" root_dir = \"/content\"\n",
"\n",
" # You might need to install condacolab on Google Colab to be able to install packages using conda / mamba\n",
" # !pip install -q condacolab\n",
" # import condacolab\n",
" # condacolab.install()\n",
"\n",
"else:\n",
" if current_spot.startswith(\"/content\"):\n",
" using_colab = True\n",
" print(\"Google Colab says hi!\")\n",
" print(\" NOTE: The scripts have not been tested on Google Colab, you might need to adapt the installations a bit.\")\n",
" root_dir = \"/content\"\n",
"\n",
" # You might need to install condacolab on Google Colab to be able to install packages using conda / mamba\n",
" # !pip install -q condacolab\n",
" # import condacolab\n",
" # condacolab.install()\n",
" \n",
" else:\n",
" msg = \"You are using your own computer or other resources. Follow our installation instructions here:\"\n",
" msg += \" https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#installation\"\n",
" print(msg)\n",
" root_dir = \"\" # overwrite to set the root directory, where the data, checkpoints, and all relevant stuff will be stored"
" msg = \"You are using a behind-the-scenes resource. Follow our installation instructions here:\"\n",
" msg += \" https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#installation\"\n",
" print(msg)\n",
" root_dir = \"\" # overwrite to set the root directory, where the data, checkpoints, and all relevant stuff will be stored"
]
},
{
Expand Down Expand Up @@ -133,6 +130,16 @@
"!pip install --quiet $tmp_dir"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Known Issues on **Kaggle Notebooks**:\n",
"\n",
"1. `warning libmamba Cache file \"/opt/conda/pkgs/cache/2ce54b42.json\" was modified by another program` (multiples lines of such warnings)\n",
" - We have received this warning while testing this notebook on Kaggle. It does not lead to any issues while making use of the installed packages. You can proceed and ignore the warnings."
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand Down Expand Up @@ -208,7 +215,7 @@
"source": [
"## Let's download the dataset\n",
"\n",
"Download the example data from zenodo."
"Download the example data from Zenodo."
]
},
{
Expand Down Expand Up @@ -558,9 +565,9 @@
" 2. If you want to improve the automatic segmentation quality, we recommend you to finetune the default SAM models OR the `µsam` models, based on your initial assessment of the segmentation quality of both models.\n",
"3. If you think the models perform poorly, we recommend you to finetune the default SAM models on your custom dataset. There are two situations here:\n",
" 1. In case you do not have any ground-truth labels, we recommend generating the desired labels using our [annotator tool](https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#annotation-tools)\n",
" 2. In case you do have ground-truth labels, we suggest going ahead with finetuning already (you can choose to use the [python scripts](TODO) or the [tool](TODO) for this.)\n",
" 2. In case you do have ground-truth labels, we suggest going ahead with finetuning already (you can choose to use the [python scripts](https://github.com/computational-cell-analytics/micro-sam/blob/master/examples/finetuning/finetune_hela.py) or the [tool](https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#finetuning-ui) for this.)\n",
" \n",
"[Here](TODO) is the link on how to get quickly started with finetuning on your custom dataset."
"[Here](https://github.com/computational-cell-analytics/micro-sam/blob/master/notebooks/sam_finetuning.ipynb) is the link to the notebook on how to get quickly started with finetuning on your custom dataset."
]
},
{
Expand Down
46 changes: 28 additions & 18 deletions notebooks/sam_finetuning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"\n",
"This notebook shows how to use Segment Anything for Microscopy to fine-tune a Segment Anything Model (SAM) on your custom data.\n",
"\n",
"We use data from the Cell Tracking Challenge (DIC-C2DH-HeLa: HeLa cells on a flat glass, see [the Cell Tracking Challenge publication](https://doi.org/10.1038/s41592-023-01879-y) for details), but these scripts will work for any kind of instance segmentation problem."
"We use DIC microscopy images from the Cell Tracking Challenge, DIC-C2DH-HeLa, HeLa cells on a flat glass (from [Maška et al.](https://www.nature.com/articles/s41592-023-01879-y)) in this notebook. The functionalities shown here should work for your (microscopy) images too."
]
},
{
Expand Down Expand Up @@ -51,31 +51,30 @@
}
],
"source": [
"# Check if we are running this notebook on kaggle, google colab or local compute resources.\n",
"\n",
"import os\n",
"current_spot = os.getcwd()\n",
"\n",
"if current_spot.startswith(\"/kaggle/working\"):\n",
" using_kaggle = True\n",
" print(\"Kaggle says hi!\")\n",
" root_dir = \"/kaggle/working\"\n",
"\n",
"elif current_spot.startswith(\"/content\"):\n",
" print(\"Google Colab says hi!\")\n",
" print(\" NOTE: The scripts have not been tested on Google Colab, you might need to adapt the installations a bit.\")\n",
" root_dir = \"/content\"\n",
"\n",
" # You might need to install condacolab on Google Colab to be able to install packages using conda / mamba\n",
" # !pip install -q condacolab\n",
" # import condacolab\n",
" # condacolab.install()\n",
"\n",
"else:\n",
" if current_spot.startswith(\"/content\"):\n",
" using_colab = True\n",
" print(\"Google Colab says hi!\")\n",
" print(\" NOTE: The scripts have not been tested on Google Colab, you might need to adapt the installations a bit.\")\n",
" root_dir = \"/content\"\n",
"\n",
" # You might need to install condacolab on Google Colab to be able to install packages using conda / mamba\n",
" # !pip install -q condacolab\n",
" # import condacolab\n",
" # condacolab.install()\n",
" \n",
" else:\n",
" msg = \"You are using a behind-the-scenes resource. Follow our installation instructions here:\"\n",
" msg += \" https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#installation\"\n",
" print(msg)\n",
" root_dir = \"\" # overwrite to set the root directory, where the data, checkpoints, and all relevant stuff will be stored"
" msg = \"You are using a behind-the-scenes resource. Follow our installation instructions here:\"\n",
" msg += \" https://computational-cell-analytics.github.io/micro-sam/micro_sam.html#installation\"\n",
" print(msg)\n",
" root_dir = \"\" # overwrite to set the root directory, where the data, checkpoints, and all relevant stuff will be stored"
]
},
{
Expand Down Expand Up @@ -162,6 +161,17 @@
"!pip install --quiet $tmp_dir"
]
},
{
"cell_type": "markdown",
"id": "a0faecec",
"metadata": {},
"source": [
"Known Issues on **Kaggle Notebooks**:\n",
"\n",
"1. `warning libmamba Cache file \"/opt/conda/pkgs/cache/2ce54b42.json\" was modified by another program` (multiples lines of such warnings)\n",
" - We have received this warning while testing this notebook on Kaggle. It does not lead to any issues while making use of the installed packages. You can proceed and ignore the warnings."
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand Down

0 comments on commit 4b2187a

Please sign in to comment.