From 1d134b00363ebe4b89920530babe4b3c3f3aa183 Mon Sep 17 00:00:00 2001 From: keejkrej Date: Wed, 28 Jan 2026 19:24:54 +0100 Subject: [PATCH 1/4] fix: trigger model download for promptable SAM/SAM2 models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add download logic to widgets.py selectModel() for segment_anything and sam2 promptable models, consistent with normal model workflow. Fixes #986 - FileNotFoundError when using segment_anything promptable model for the first time because weights weren't downloaded. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cellacdc/widgets.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cellacdc/widgets.py b/cellacdc/widgets.py index d9da7f54..bfbe1b18 100755 --- a/cellacdc/widgets.py +++ b/cellacdc/widgets.py @@ -11102,7 +11102,12 @@ def selectModel(self): model_name = win.model_name print(f'Importing promptable model {model_name}...') - + + # Download model weights if needed (consistent with normal model workflow) + if model_name in ('segment_anything', 'sam2'): + downloadWin = apps.downloadModel(model_name, parent=self._parent) + downloadWin.download() + acdcPromptSegment = myutils.import_promptable_segment_module(model_name) init_argspecs, segment_argspecs = myutils.getModelArgSpec( acdcPromptSegment From 015a7fc89fe2aa812d30b9ca97bdba48156a2493 Mon Sep 17 00:00:00 2001 From: keejkrej Date: Wed, 28 Jan 2026 19:26:58 +0100 Subject: [PATCH 2/4] moved matplotlib to main dependency --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 15dffc5b..d6e76ee3 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ dependencies = [ "boto3", "requests", "setuptools-scm", + "matplotlib" ] dynamic = [ "version", @@ -148,7 +149,6 @@ all = [ dev = [ "pytest", "pytest-cov", - "matplotlib", ] [project.scripts] From a433fd7ce6de5225a01f4bee65cc9ec02ae895fa Mon Sep 17 00:00:00 2001 From: keejkrej Date: Wed, 28 Jan 2026 19:51:35 +0100 Subject: [PATCH 3/4] fix: add sam2_weights_filenames for download dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add sam2_weights_filenames to __init__.py so check_model_exists() works correctly for SAM2. This ensures the download warning dialog appears before downloading SAM2 weights, consistent with other models. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- cellacdc/__init__.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cellacdc/__init__.py b/cellacdc/__init__.py index 2b73f7b0..75919f66 100755 --- a/cellacdc/__init__.py +++ b/cellacdc/__init__.py @@ -525,11 +525,18 @@ def printl(*objects, pretty=False, is_decorator=False, idx=1, **kwargs): ] segment_anything_weights_filenames = [ - 'sam_vit_h_4b8939.pth', - 'sam_vit_l_0b3195.pth', + 'sam_vit_h_4b8939.pth', + 'sam_vit_l_0b3195.pth', 'sam_vit_b_01ec64.pth' ] +sam2_weights_filenames = [ + 'sam2.1_hiera_large.pt', + 'sam2.1_hiera_base_plus.pt', + 'sam2.1_hiera_small.pt', + 'sam2.1_hiera_tiny.pt' +] + deepsea_weights_filenames = [ 'segmentation.pth', 'tracker.pth' From c57442cf71103cbc7bbcd54f73ea802cf61c7c2f Mon Sep 17 00:00:00 2001 From: keejkrej Date: Thu, 29 Jan 2026 10:26:23 +0100 Subject: [PATCH 4/4] fix: trigger model download for all promptable models Remove the model name check so download is triggered for all promptable models, consistent with gui.py behavior. Co-Authored-By: Claude Opus 4.5 --- cellacdc/widgets.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cellacdc/widgets.py b/cellacdc/widgets.py index bfbe1b18..73933aba 100755 --- a/cellacdc/widgets.py +++ b/cellacdc/widgets.py @@ -11103,10 +11103,9 @@ def selectModel(self): model_name = win.model_name print(f'Importing promptable model {model_name}...') - # Download model weights if needed (consistent with normal model workflow) - if model_name in ('segment_anything', 'sam2'): - downloadWin = apps.downloadModel(model_name, parent=self._parent) - downloadWin.download() + # Download model weights, consistent with gui.py + downloadWin = apps.downloadModel(model_name, parent=self._parent) + downloadWin.download() acdcPromptSegment = myutils.import_promptable_segment_module(model_name) init_argspecs, segment_argspecs = myutils.getModelArgSpec(