diff --git a/cellpose_napari/_dock_widget.py b/cellpose_napari/_dock_widget.py index 87723f8..674d065 100644 --- a/cellpose_napari/_dock_widget.py +++ b/cellpose_napari/_dock_widget.py @@ -10,6 +10,8 @@ from napari import Viewer from napari.layers import Image, Shapes +from napari.utils.notifications import show_info + from magicgui import magicgui import sys @@ -58,7 +60,7 @@ def _deco(func): return func return _deco - @thread_worker + @thread_worker(progress=True) @no_grad() def run_cellpose(image, model_type, custom_model, channels, channel_axis, diameter, resample, cellprob_threshold, @@ -69,12 +71,16 @@ def run_cellpose(image, model_type, custom_model, channels, channel_axis, diamet flow_threshold = 0.0 logger.debug('flow_threshold=0 => no masks thrown out due to model mismatch') logger.debug(f'computing masks with cellprob_threshold={cellprob_threshold}, flow_threshold={flow_threshold}') + + show_info('(Down)Loading models...') + if model_type=='custom': CP = models.CellposeModel(pretrained_model=custom_model, gpu=True) else: CP = models.CellposeModel(model_type=model_type, gpu=True) - print(cellprob_threshold, flow_threshold) + show_info('Running Segmentation...') + masks, flows_orig, _ = CP.eval(image, channels=channels, channel_axis=channel_axis, @@ -94,7 +100,7 @@ def run_cellpose(image, model_type, custom_model, channels, channel_axis, diamet flows_orig = flows return masks, flows_orig - @thread_worker + @thread_worker(progress=True) def compute_diameter(image, channels, model_type): from cellpose import models model_type0 = model_type if model_type in CP_models[:4] else "cyto3" @@ -105,7 +111,7 @@ def compute_diameter(image, channels, model_type): del CP return diam - @thread_worker + @thread_worker(progress=True) def compute_masks(masks_orig, flows_orig, cellprob_threshold, flow_threshold): from cellpose.dynamics import resize_and_compute_masks