Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add basic progress indicator & activity info #33

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions cellpose_napari/_dock_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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"
Expand All @@ -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

Expand Down
Loading