diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml
index 1a8b0e5b..cb581b79 100644
--- a/.github/workflows/test_and_deploy.yml
+++ b/.github/workflows/test_and_deploy.yml
@@ -51,6 +51,8 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install setuptools tox tox-gh-actions
+ python -m pip install tifffile
+ python -m pip install monai[nibabel,einops,tifffile]
# pip install git+https://github.com/lucasb-eyer/pydensecrf.git@master#egg=pydensecrf
# this runs the platform-specific tests declared in tox.ini
diff --git a/conda/napari_CellSeg3D_ARM64.yml b/conda/napari_CellSeg3D_ARM64.yml
index 49de0f12..de850061 100644
--- a/conda/napari_CellSeg3D_ARM64.yml
+++ b/conda/napari_CellSeg3D_ARM64.yml
@@ -18,7 +18,7 @@ dependencies:
- monai[nibabel, einops]>=0.9.0
- tqdm
- scikit-image
- - pyclesperanto-prototype
+ - pyclesperanto
- tqdm
- matplotlib
- napari_cellseg3d
diff --git a/docs/welcome.rst b/docs/welcome.rst
index 4f75c17b..652d880b 100644
--- a/docs/welcome.rst
+++ b/docs/welcome.rst
@@ -168,7 +168,7 @@ This plugin additionally uses the following libraries and software:
.. _PyTorch: https://pytorch.org/
.. _MONAI project: https://monai.io/
.. _on their website: https://docs.monai.io/en/stable/networks.html#nets
-.. _pyclEsperanto: https://github.com/clEsperanto/pyclesperanto_prototype
+.. _pyclEsperanto: https://github.com/clEsperanto/pyclesperanto
.. _WNet: https://arxiv.org/abs/1711.08506
.. rubric:: References
diff --git a/napari_cellseg3d/code_models/instance_segmentation.py b/napari_cellseg3d/code_models/instance_segmentation.py
index dbc903d3..754a996f 100644
--- a/napari_cellseg3d/code_models/instance_segmentation.py
+++ b/napari_cellseg3d/code_models/instance_segmentation.py
@@ -6,7 +6,7 @@
from typing import List
import numpy as np
-import pyclesperanto_prototype as cle
+import pyclesperanto as cle
from qtpy.QtWidgets import QWidget
from skimage.measure import label, regionprops
from skimage.morphology import remove_small_objects
@@ -287,7 +287,7 @@ def voronoi_otsu(
BASED ON CODE FROM : napari_pyclesperanto_assistant by Robert Haase
https://github.com/clEsperanto/napari_pyclesperanto_assistant
Original code at :
- https://github.com/clEsperanto/pyclesperanto_prototype/blob/master/pyclesperanto_prototype/_tier9/_voronoi_otsu_labeling.py.
+ https://github.com/clEsperanto/pyclesperanto/blob/d1990e28b1da44a7921890b7bd809d522d3198b8/pyclesperanto/_tier7.py#L409-L448.
Args:
volume (np.ndarray): volume to segment
diff --git a/napari_cellseg3d/code_models/models/model_SwinUNetR.py b/napari_cellseg3d/code_models/models/model_SwinUNetR.py
index 1335b388..f90ef1df 100644
--- a/napari_cellseg3d/code_models/models/model_SwinUNetR.py
+++ b/napari_cellseg3d/code_models/models/model_SwinUNetR.py
@@ -1,5 +1,7 @@
"""SwinUNetR wrapper for napari_cellseg3d."""
+import inspect
+
from monai.networks.nets import SwinUNETR
from napari_cellseg3d.utils import LOGGER
@@ -30,30 +32,30 @@ def __init__(
use_checkpoint (bool): whether to use checkpointing during training.
**kwargs: additional arguments to SwinUNETR.
"""
+ parent_init = super().__init__
+ sig = inspect.signature(parent_init)
+ init_kwargs = dict(
+ in_channels=in_channels,
+ out_channels=out_channels,
+ use_checkpoint=use_checkpoint,
+ feature_size=48,
+ drop_rate=0.5,
+ attn_drop_rate=0.5,
+ use_v2=True,
+ **kwargs,
+ )
+ if "img_size" in sig.parameters:
+ # since MONAI API changes depending on py3.8 or py3.9
+ init_kwargs["img_size"] = input_img_size
+ if "dropout_prob" in kwargs:
+ init_kwargs["drop_rate"] = kwargs["dropout_prob"]
+ init_kwargs.pop("dropout_prob")
try:
- super().__init__(
- input_img_size,
- in_channels=in_channels,
- out_channels=out_channels,
- feature_size=48,
- use_checkpoint=use_checkpoint,
- drop_rate=0.5,
- attn_drop_rate=0.5,
- use_v2=True,
- **kwargs,
- )
+ parent_init(**init_kwargs)
except TypeError as e:
logger.warning(f"Caught TypeError: {e}")
- super().__init__(
- input_img_size,
- in_channels=1,
- out_channels=1,
- feature_size=48,
- use_checkpoint=use_checkpoint,
- drop_rate=0.5,
- attn_drop_rate=0.5,
- use_v2=True,
- )
+ init_kwargs["in_channels"] = 1
+ parent_init(**init_kwargs)
# def forward(self, x_in):
# y = super().forward(x_in)
diff --git a/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py b/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py
index e644cd8d..2585d900 100644
--- a/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py
+++ b/napari_cellseg3d/dev_scripts/sliding_window_voronoi.py
@@ -1,6 +1,6 @@
"""Test script for sliding window Voronoi-Otsu segmentation.""."""
import numpy as np
-import pyclesperanto_prototype as cle
+import pyclesperanto as cle
from tqdm import tqdm
diff --git a/notebooks/Colab_inference_demo.ipynb b/notebooks/Colab_inference_demo.ipynb
index e5d3888e..ff673d4f 100644
--- a/notebooks/Colab_inference_demo.ipynb
+++ b/notebooks/Colab_inference_demo.ipynb
@@ -3,8 +3,8 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "view-in-github",
- "colab_type": "text"
+ "colab_type": "text",
+ "id": "view-in-github"
},
"source": [
"
"
@@ -48,8 +48,8 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "id": "bnFKu6uFAm-z",
- "collapsed": true
+ "collapsed": true,
+ "id": "bnFKu6uFAm-z"
},
"outputs": [],
"source": [
@@ -151,28 +151,28 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": null,
"metadata": {
- "id": "O0jLRpARAm-0",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 35
},
+ "id": "O0jLRpARAm-0",
"outputId": "e4e8549c-7100-4c0c-bc30-505c0dfeb138"
},
"outputs": [
{
- "output_type": "execute_result",
"data": {
- "text/plain": [
- "'cupy backend (experimental)'"
- ],
"application/vnd.google.colaboratory.intrinsic+json": {
"type": "string"
- }
+ },
+ "text/plain": [
+ "'cupy backend (experimental)'"
+ ]
},
+ "execution_count": 4,
"metadata": {},
- "execution_count": 4
+ "output_type": "execute_result"
}
],
"source": [
@@ -181,45 +181,50 @@
"inference_config = cs3d.CONFIG\n",
"post_process_config = cs3d.PostProcessConfig()\n",
"# select cle device for colab\n",
- "import pyclesperanto_prototype as cle\n",
- "cle.select_device(\"cupy\")"
+ "import pyclesperanto as cle\n",
+ "cle.select_device()"
]
},
{
"cell_type": "markdown",
- "source": [
- "### Select the pretrained model"
- ],
"metadata": {
"id": "b6vIW_oDlpok"
- }
+ },
+ "source": [
+ "### Select the pretrained model"
+ ]
},
{
"cell_type": "code",
- "source": [
- "model_selection = \"SwinUNetR\" #@param [\"SwinUNetR\", \"WNet3D\", \"SegResNet\"]\n",
- "print(f\"Selected model: {model_selection}\")"
- ],
+ "execution_count": 5,
"metadata": {
- "id": "5tkEI1q-loqB",
"colab": {
"base_uri": "https://localhost:8080/"
},
+ "id": "5tkEI1q-loqB",
"outputId": "d41875da-3879-4158-8a0f-6330afe442af"
},
- "execution_count": 5,
"outputs": [
{
- "output_type": "stream",
"name": "stdout",
+ "output_type": "stream",
"text": [
"Selected model: SwinUNetR\n"
]
}
+ ],
+ "source": [
+ "model_selection = \"SwinUNetR\" #@param [\"SwinUNetR\", \"WNet3D\", \"SegResNet\"]\n",
+ "print(f\"Selected model: {model_selection}\")"
]
},
{
"cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "id": "aPFS4WTdmPo3"
+ },
+ "outputs": [],
"source": [
"from napari_cellseg3d.config import ModelInfo\n",
"\n",
@@ -229,27 +234,22 @@
" num_classes=2,\n",
")\n",
"inference_config.model_info = model_info"
- ],
- "metadata": {
- "id": "aPFS4WTdmPo3"
- },
- "execution_count": 6,
- "outputs": []
+ ]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
- "id": "hIEKoyEGAm-0",
"colab": {
"base_uri": "https://localhost:8080/"
},
+ "id": "hIEKoyEGAm-0",
"outputId": "2103baf6-8875-433b-8799-41e0d1f3c7f0"
},
"outputs": [
{
- "output_type": "stream",
"name": "stdout",
+ "output_type": "stream",
"text": [
"--------------------\n",
"Parameters summary :\n",
@@ -265,23 +265,23 @@
]
},
{
- "output_type": "stream",
"name": "stderr",
+ "output_type": "stream",
"text": [
"monai.networks.nets.swin_unetr SwinUNETR.__init__:img_size: Argument `img_size` has been deprecated since version 1.3. It will be removed in version 1.5. The img_size argument is not required anymore and checks on the input size are run during forward().\n",
"INFO:napari_cellseg3d.utils:********************\n"
]
},
{
- "output_type": "stream",
"name": "stdout",
+ "output_type": "stream",
"text": [
"Loading weights...\n"
]
},
{
- "output_type": "stream",
"name": "stderr",
+ "output_type": "stream",
"text": [
"INFO:napari_cellseg3d.utils:Downloading the model from HuggingFace https://huggingface.co/C-Achard/cellseg3d/resolve/main/SwinUNetR_latest.tar.gz....\n",
"270729216B [00:10, 26012663.01B/s] \n",
@@ -289,8 +289,8 @@
]
},
{
- "output_type": "stream",
"name": "stdout",
+ "output_type": "stream",
"text": [
"Weights status : \n",
"Done\n",
@@ -325,16 +325,16 @@
"cell_type": "code",
"execution_count": 8,
"metadata": {
- "id": "IFbmZ3_zAm-1",
"colab": {
"base_uri": "https://localhost:8080/"
},
+ "id": "IFbmZ3_zAm-1",
"outputId": "bde6a6c5-f47f-4164-9e1c-3bf5a94dd00d"
},
"outputs": [
{
- "output_type": "stream",
"name": "stderr",
+ "output_type": "stream",
"text": [
"1it [00:00, 9.61it/s]\n",
"clesperanto's cupy / CUDA backend is experimental. Please use it with care. The following functions are known to cause issues in the CUDA backend:\n",
@@ -362,7 +362,6 @@
"cell_type": "code",
"execution_count": 9,
"metadata": {
- "id": "TMRiQ-m4Am-1",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 496,
@@ -376,29 +375,26 @@
"10441f745a6f41cf8655b2fafbb8204f"
]
},
+ "id": "TMRiQ-m4Am-1",
"outputId": "2d819126-5478-4d98-a5e2-ecacb7872465"
},
"outputs": [
{
- "output_type": "display_data",
"data": {
- "text/plain": [
- "interactive(children=(IntSlider(value=62, description='z', max=123), Output()), _dom_classes=('widget-interact…"
- ],
"application/vnd.jupyter.widget-view+json": {
+ "model_id": "7a72ee57e14c440bb2ce281da67e1311",
"version_major": 2,
- "version_minor": 0,
- "model_id": "7a72ee57e14c440bb2ce281da67e1311"
- }
+ "version_minor": 0
+ },
+ "text/plain": [
+ "interactive(children=(IntSlider(value=62, description='z', max=123), Output()), _dom_classes=('widget-interact…"
+ ]
},
- "metadata": {}
+ "metadata": {},
+ "output_type": "display_data"
},
{
- "output_type": "execute_result",
"data": {
- "text/plain": [
- ""
- ],
"text/html": [
"