diff --git a/README.md b/README.md index 09252dab..7021fe63 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,13 @@ The strength of our approach is we can match supervised model performance with p ![FIG1 (1)](https://github.com/user-attachments/assets/0d970b45-79ff-4c58-861f-e1e7dc9abc65) -**Figure 1. Performance of 3D Semantic and Instance Segmentation Models.** -**a:** Raw mesoSPIM whole-brain sample, volumes and corresponding ground truth labels from somatosensory (S1) and visual (V1) cortical regions. +**Figure 1. Performance of 3D Semantic and Instance Segmentation Models.** +**a:** Raw mesoSPIM whole-brain sample, volumes and corresponding ground truth labels from somatosensory (S1) and visual (V1) cortical regions. **b:** Evaluation of instance segmentation performance for baseline thresholding-only, supervised models: Cellpose, StartDist, SwinUNetR, SegResNet, and our self-supervised model WNet3D over three data subsets. F1-score is computed from the Intersection over Union (IoU) with ground truth labels, then averaged. Error bars represent 50% Confidence Intervals -(CIs). -**c:** View of 3D instance labels from supervised models, as noted, for visual cortex volume in b evaluation. +(CIs). +**c:** View of 3D instance labels from supervised models, as noted, for visual cortex volume in b evaluation. **d:** Illustration of our WNet3D architecture showcasing the dual 3D U-Net structure with our modifications. @@ -141,7 +141,7 @@ Before testing, install all requirements using ``pip install napari-cellseg3d[te To run tests locally: -- Locally : run ``pytest`` in the plugin folder +- Locally : run ``pytest napari_cellseg3d\_tests`` in the plugin folder. - Locally with coverage : In the plugin folder, run ``coverage run --source=napari_cellseg3d -m pytest`` then ``coverage xml`` to generate a .xml coverage file. - With tox : run ``tox`` in the plugin folder (will simulate tests with several python and OS configs, requires substantial storage space) diff --git a/napari_cellseg3d/code_models/crf.py b/napari_cellseg3d/code_models/crf.py index 4fa2264c..b70c92e4 100644 --- a/napari_cellseg3d/code_models/crf.py +++ b/napari_cellseg3d/code_models/crf.py @@ -18,6 +18,7 @@ Implemented using the pydense library available at https://github.com/lucasb-eyer/pydensecrf. """ + import importlib import numpy as np @@ -28,13 +29,7 @@ spec = importlib.util.find_spec("pydensecrf") CRF_INSTALLED = spec is not None -if not CRF_INSTALLED: - logger.info( - "pydensecrf not installed, CRF post-processing will not be available. " - "Please install by running : pip install pydensecrf " - "This is not a hard requirement, you do not need it to install it unless you want to use the CRF post-processing step. " - ) -else: +if CRF_INSTALLED: import pydensecrf.densecrf as dcrf from pydensecrf.utils import ( create_pairwise_bilateral, @@ -124,6 +119,11 @@ def crf(image, prob, sa, sb, sg, w1, w2, n_iter=5): np.ndarray: Array of shape (K, H, W, D) containing the refined class probabilities for each pixel. """ if not CRF_INSTALLED: + logger.info( + "pydensecrf not installed, CRF post-processing will not be available. " + "Please install by running : pip install pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master" + "This is not a hard requirement, you do not need it to install it unless you want to use the CRF post-processing step." + ) return None d = dcrf.DenseCRF( @@ -232,7 +232,12 @@ def __init__( def _run_crf_job(self): """Runs the CRF post-processing step for the W-Net.""" if not CRF_INSTALLED: - raise ImportError("pydensecrf is not installed.") + logger.info( + "pydensecrf not installed, CRF post-processing will not be available. " + "Please install by running : pip install pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master" + "This is not a hard requirement, you do not need it to install it unless you want to use the CRF post-processing step." + ) + # raise ImportError("pydensecrf is not installed.") if len(self.images) != len(self.labels): raise ValueError("Number of images and labels must be the same.") diff --git a/pyproject.toml b/pyproject.toml index ed02dcc1..c5f566a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,9 +123,6 @@ profile = "black" line_length = 79 [project.optional-dependencies] -crf = [ - # "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", -] pyqt5 = [ "pyqt5", ] @@ -164,7 +161,6 @@ test = [ "coverage", "tox", "twine", - # "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", "onnx", "onnxruntime", ]