Skip to content

Commit

Permalink
Remove optional CRF dep+update warning
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Achard committed Dec 23, 2024
1 parent 8c6c306 commit 6d8adbb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down Expand Up @@ -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)

Expand Down
21 changes: 13 additions & 8 deletions napari_cellseg3d/code_models/crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Implemented using the pydense library available at https://github.com/lucasb-eyer/pydensecrf.
"""

import importlib

import numpy as np
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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.")
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down Expand Up @@ -164,7 +161,6 @@ test = [
"coverage",
"tox",
"twine",
# "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master",
"onnx",
"onnxruntime",
]

0 comments on commit 6d8adbb

Please sign in to comment.