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

ValueError: '2D_versatile_fluo' is neither a key or alias for 'StarDist3D' #15

Closed
psobolewskiPhD opened this issue Apr 3, 2022 · 5 comments

Comments

@psobolewskiPhD
Copy link
Contributor

psobolewskiPhD commented Apr 3, 2022

Just updated to the latest version:

╰─ pip show stardist-napari                                      (apple-TF28) ─╯
Name: stardist-napari
Version: 2022.3.30

With the 2D nuclei sample open launching the plugin gives an error:
ValueError: '2D_versatile_fluo' is neither a key or alias for 'StarDist3D'

ValueError                                Traceback (most recent call last)
File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/superqt/utils/_qthreading.py:616, in create_worker.<locals>.reraise(e=ValueError("'2D_versatile_fluo' is neither a key or alias for 'StarDist3D'"))
    615 def reraise(e):
--> 616     raise e
        e = ValueError("'2D_versatile_fluo' is neither a key or alias for 'StarDist3D'")

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/superqt/utils/_qthreading.py:176, in WorkerBase.run(self=<napari._qt.qthreading.FunctionWorker object>)
    174     warnings.filterwarnings("always")
    175     warnings.showwarning = lambda *w: self.warned.emit(w)
--> 176     result = self.work()
        self = <napari._qt.qthreading.FunctionWorker object at 0x2a7fdaa60>
    177 if isinstance(result, Exception):
    178     if isinstance(result, RuntimeError):
    179         # The Worker object has likely been deleted.
    180         # A deleted wrapped C/C++ object may result in a runtime
    181         # error that will cause segfault if we try to do much other
    182         # than simply notify the user.

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/superqt/utils/_qthreading.py:356, in FunctionWorker.work(self=<napari._qt.qthreading.FunctionWorker object>)
    355 def work(self) -> _R:
--> 356     return self._func(*self._args, **self._kwargs)
        self._func = <function plugin_wrapper.<locals>._model_change.<locals>._get_model_folder at 0x2a7fdac10>
        self = <napari._qt.qthreading.FunctionWorker object at 0x2a7fdaa60>
        self._args = ()
        self._kwargs = {}

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/stardist_napari/_dock_widget.py:1007, in plugin_wrapper.<locals>._model_change.<locals>._get_model_folder()
   1005 @thread_worker
   1006 def _get_model_folder():
-> 1007     return get_model_folder(*key)
        key = (<class 'stardist.models.model3d.StarDist3D'>, '2D_versatile_fluo')

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/csbdeep/models/pretrained.py:92, in get_model_folder(cls=<class 'stardist.models.model3d.StarDist3D'>, key_or_alias='2D_versatile_fluo')
     91 def get_model_folder(cls, key_or_alias):
---> 92     key, alias, m = get_model_details(cls, key_or_alias)
        cls = <class 'stardist.models.model3d.StarDist3D'>
        key_or_alias = '2D_versatile_fluo'
     93     target = str(Path('models') / cls.__name__ / key)
     94     path = Path(get_file(fname=key+'.zip', origin=m['url'], file_hash=m['hash'],
     95                          cache_subdir=target, extract=True))

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/csbdeep/models/pretrained.py:83, in get_model_details(cls=<class 'stardist.models.model3d.StarDist3D'>, key_or_alias='2D_versatile_fluo', verbose=False)
     81     aliases = _ALIASES.get(cls,{})
     82     alias = key_or_alias
---> 83     alias in aliases or _raise(ValueError("'%s' is neither a key or alias for '%s'" % (alias, cls.__name__)))
        cls = <class 'stardist.models.model3d.StarDist3D'>
        alias = '2D_versatile_fluo'
        aliases = {}
        alias in aliases = False
     84     key = aliases[alias]
     85 if verbose:

File ~/Dev/miniforge3/envs/apple-TF28/lib/python3.9/site-packages/csbdeep/utils/utils.py:91, in _raise(e=ValueError("'2D_versatile_fluo' is neither a key or alias for 'StarDist3D'"))
     89 def _raise(e):
     90     if isinstance(e, BaseException):
---> 91         raise e
        e = ValueError("'2D_versatile_fluo' is neither a key or alias for 'StarDist3D'")
     92     else:
     93         raise ValueError(e)

ValueError: '2D_versatile_fluo' is neither a key or alias for 'StarDist3D'

Also, the widget shows Downloading progress bar, but I don't see any data transmitted. The model should be already on disc, because I can use stardist programatically just fine...

Name: stardist
Version: 0.8.0

Edit1:
Here's a screenshot:
image
Edit2:
Using Nuclei 3D and 3D model works fine, so somehow all model choices are compared vs. StarDist3D.

@psobolewskiPhD
Copy link
Contributor Author

I've done some poking around.
the problem is definitely here:

model_class = StarDist2D if Signal.sender() is plugin.model2d else StarDist3D

If I change the else to StarDist2D then the 2D models start working and 3D fail.
Also adding a print(Signal.sender()) returns None so it appears that this is the issue: the if is never triggered so the else is always returned.

@uschmidt83
Copy link
Member

Thanks for the bug report, @psobolewskiPhD. Unfortunately, I can't reproduce this.

(@tlambert03, could this be due to the recent Signal change in #14?)

@tlambert03
Copy link
Contributor

Anything possible, but the only thing that changed in #14 was where the import occurred (the object didn't change)

@psobolewskiPhD
Copy link
Contributor Author

psobolewskiPhD commented Apr 3, 2022

I had magicgui at 0.3.7 from: https://forum.image.sc/t/stardist-napari-plugin-not-working/65032/8?u=psobolewskiphd
Upgrading to 0.4.0 solves the issue.
pip install magicgui==0.3.7 makes it occur again.
Perhaps that means that the pin for magicgui should move up to 0.4.0?
Edit: To be clear, I had magicgui 0.3.7 when I upgraded stardist-napari using the napari plugin doohickey. That broke the 2d model for me. Upgrading magicgui to 0.4.0 fixes the problem.

@uschmidt83
Copy link
Member

I had magicgui at 0.3.7 from: https://forum.image.sc/t/stardist-napari-plugin-not-working/65032/8?u=psobolewskiphd
Upgrading to 0.4.0 solves the issue.
pip install magicgui==0.3.7 makes it occur again.

I can reproduce the issue with magicgui 0.3.7.

Perhaps that means that the pin for magicgui should move up to 0.4.0?

Probably the easiest... but I have no idea if this restrictive to some users or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants