Skip to content

Commit

Permalink
Fixes for UI and tests
Browse files Browse the repository at this point in the history
- Fix SegResNet input dims in test
- Fixed all tests
- Fixed issues with window inference settings for WNet in UI
  • Loading branch information
C-Achard committed Jul 28, 2023
1 parent 78f72dd commit 8d0ff5d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions napari_cellseg3d/_tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_model_list():
for model_name in MODEL_LIST:
# if model_name=="test":
# continue
dims = 128
dims = 64
test = MODEL_LIST[model_name](
input_img_size=[dims, dims, dims],
in_channels=1,
Expand Down Expand Up @@ -114,7 +114,7 @@ def test_pretrained_weights_compatibility():
for model_name in MODEL_LIST:
file_name = MODEL_LIST[model_name].weights_file
WeightsDownloader().download_weights(model_name, file_name)
model = MODEL_LIST[model_name](input_img_size=[128, 128, 128])
model = MODEL_LIST[model_name](input_img_size=[64, 64, 64])
try:
model.load_state_dict(
torch.load(
Expand Down
26 changes: 7 additions & 19 deletions napari_cellseg3d/code_plugins/plugin_model_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):
######################
# TODO : better way to handle SegResNet size reqs ?
self.model_input_size = ui.IntIncrementCounter(
lower=1, upper=1024, default=128, text_label="\nModel input size"
lower=1, upper=1024, default=64, text_label="\nModel input size"
)
self.model_choice.currentIndexChanged.connect(
self._toggle_display_model_input_size
Expand Down Expand Up @@ -155,16 +155,7 @@ def __init__(self, viewer: "napari.viewer.Viewer", parent=None):

sizes_window = ["8", "16", "32", "64", "128", "256", "512"]
self._default_window_size = sizes_window.index("64")
# (
# self.window_size_choice,
# self.window_size_choice.label,
# ) = ui.make_combobox(sizes_window, label="Window size and overlap")
# self.window_overlap = ui.make_n_spinboxes(
# max=1,
# default=0.7,
# step=0.05,
# double=True,
# )
self.wnet_enabled = False

self.window_size_choice = ui.DropdownMenu(
sizes_window, text_label="Window size"
Expand Down Expand Up @@ -310,16 +301,13 @@ def check_ready(self):

def _restrict_window_size_for_model(self):
"""Sets the window size to a value that is compatible with the chosen model"""
self.wnet_enabled = False
if self.model_choice.currentText() == "WNet":
self.window_size_choice.setCurrentIndex(self._default_window_size)
self.window_size_choice.setDisabled(True)
self.window_infer_box.setChecked(True)
self.window_infer_box.setDisabled(True)
else:
self.window_size_choice.setDisabled(False)
self.window_infer_box.setDisabled(False)
self.window_infer_box.setChecked(True)
self.window_size_choice.setCurrentIndex(self._default_window_size)
self.wnet_enabled = True
self.window_infer_box.setChecked(self.wnet_enabled)
self.window_size_choice.setDisabled(self.wnet_enabled)
self.window_infer_box.setDisabled(self.wnet_enabled)

def _toggle_display_model_input_size(self):
if (
Expand Down

0 comments on commit 8d0ff5d

Please sign in to comment.