From 95d859d2ed36157e282c9837d44c8a510969b0b2 Mon Sep 17 00:00:00 2001 From: C-Achard Date: Sat, 19 Oct 2024 14:53:26 +0200 Subject: [PATCH 1/5] Fix default mutables in config --- napari_cellseg3d/config.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/napari_cellseg3d/config.py b/napari_cellseg3d/config.py index f319802d..eb3a090b 100644 --- a/napari_cellseg3d/config.py +++ b/napari_cellseg3d/config.py @@ -1,6 +1,6 @@ """Module to store configuration parameters for napari_cellseg3d.""" import datetime -from dataclasses import dataclass +from dataclasses import dataclass, field from pathlib import Path from typing import List, Optional @@ -182,9 +182,9 @@ class PostProcessConfig: instance (InstanceSegConfig): instance segmentation config """ - zoom: Zoom = Zoom() - thresholding: Thresholding = Thresholding() - instance: InstanceSegConfig = InstanceSegConfig() + zoom: Zoom = field(default_factory=Zoom) + thresholding: Thresholding = field(default_factory=Thresholding) + instance: InstanceSegConfig = field(default_factory=InstanceSegConfig) artifact_removal: bool = False artifact_removal_size: int = 500 @@ -265,16 +265,16 @@ class InferenceWorkerConfig: """ device: str = "cpu" - model_info: ModelInfo = ModelInfo() - weights_config: WeightsInfo = WeightsInfo() + model_info: ModelInfo = field(default_factory=ModelInfo) + weights_config: WeightsInfo = field(default_factory=WeightsInfo) results_path: str = str(Path.home() / "cellseg3d" / "inference") filetype: str = ".tif" keep_on_cpu: bool = False compute_stats: bool = False - post_process_config: PostProcessConfig = PostProcessConfig() - sliding_window_config: SlidingWindowConfig = SlidingWindowConfig() + post_process_config: PostProcessConfig = field(default_factory=PostProcessConfig) + sliding_window_config: SlidingWindowConfig = field(default_factory=SlidingWindowConfig) use_crf: bool = False - crf_config: CRFConfig = CRFConfig() + crf_config: CRFConfig = field(default_factory=CRFConfig) images_filepaths: List[str] = None layer: napari.layers.Layer = None @@ -329,10 +329,10 @@ class TrainingWorkerConfig: learning_rate: np.float64 = 1e-3 validation_interval: int = 2 batch_size: int = 1 - deterministic_config: DeterministicConfig = DeterministicConfig() + deterministic_config: DeterministicConfig = field(default_factory=DeterministicConfig) scheduler_factor: float = 0.5 scheduler_patience: int = 10 - weights_info: WeightsInfo = WeightsInfo() + weights_info: WeightsInfo = field(default_factory=WeightsInfo) # data params results_path_folder: str = str(Path.home() / "cellseg3d" / "training") sampling: bool = False From 92201025c3b46ef8be8134d5def76de119d76e0d Mon Sep 17 00:00:00 2001 From: C-Achard Date: Sat, 19 Oct 2024 15:16:57 +0200 Subject: [PATCH 2/5] Re-enable CRF optional dependency --- pyproject.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b0a7b711..4ecbb5cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,9 +123,9 @@ profile = "black" line_length = 79 [project.optional-dependencies] -#crf = [ -# "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", -#] +crf = [ + "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", +] pyqt5 = [ "pyqt5", ] @@ -164,7 +164,7 @@ test = [ "coverage", "tox", "twine", -# "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", + "pydensecrf@git+https://github.com/lucasb-eyer/pydensecrf.git#egg=master", "onnx", "onnxruntime", ] From 34a59a38d0e625350dae8d7c2f4e375c855829e1 Mon Sep 17 00:00:00 2001 From: C-Achard Date: Sat, 19 Oct 2024 16:04:35 +0200 Subject: [PATCH 3/5] Fix layer set to invisible causing test errors --- napari_cellseg3d/code_plugins/plugin_crop.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/napari_cellseg3d/code_plugins/plugin_crop.py b/napari_cellseg3d/code_plugins/plugin_crop.py index e8bad56d..93f5680f 100644 --- a/napari_cellseg3d/code_plugins/plugin_crop.py +++ b/napari_cellseg3d/code_plugins/plugin_crop.py @@ -75,7 +75,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None): self.create_new_layer = ui.CheckBox("Create new layers") self.create_new_layer.setToolTip( - 'Use this to create a new layer everytime you start cropping, so you can "zoom in" your volume' + 'Use this to create a new layer every time you start cropping, so you can "zoom in" your volume' ) self._viewer.layers.events.inserted.connect(self._check_image_list) @@ -324,8 +324,9 @@ def _start(self): if self.crop_second_image: self.image_layer2 = self._add_isotropic_layer( - self.image_layer2, visible=False + self.image_layer2 ) + self.image_layer2.visible = False else: self.image_layer1.opacity = 0.7 self.image_layer1.colormap = "inferno" From ee9977d715c09cc57fbe65fc41f4388b7daf709e Mon Sep 17 00:00:00 2001 From: C-Achard Date: Sat, 19 Oct 2024 16:04:43 +0200 Subject: [PATCH 4/5] Update README.md --- examples/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/README.md b/examples/README.md index 000f56c7..5b0e8ab8 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,6 +1,7 @@ # Testing CellSeg3D on demo data Here is a very small volume (from [IDR project 853](https://idr.openmicroscopy.org/webclient/?show=project-853)) to test on. +All credits to the original authors of the data. You can install, launch `napari`, activate the CellSeg3D plugin app, and drag & drop this volume into the canvas. Then, for example, run `inference` with one of our models. From bb0b08b86f8aeed1a8b7a70dcf4b156508712756 Mon Sep 17 00:00:00 2001 From: C-Achard Date: Sat, 19 Oct 2024 16:07:14 +0200 Subject: [PATCH 5/5] Update credits for example data --- examples/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/README.md b/examples/README.md index 5b0e8ab8..be6ea1c4 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,7 +3,6 @@ Here is a very small volume (from [IDR project 853](https://idr.openmicroscopy.org/webclient/?show=project-853)) to test on. All credits to the original authors of the data. You can install, launch `napari`, activate the CellSeg3D plugin app, and drag & drop this volume into the canvas. -Then, for example, run `inference` with one of our models. - -See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details. +Then, for example, run the `Inference` module with one of our models. +See [CellSeg3D documentation](https://adaptivemotorcontrollab.github.io/CellSeg3D/welcome.html) for more details. \ No newline at end of file