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

TypeError: eval() got an unexpected keyword argument 'net_avg' #50

Closed
LeungKamdayjat opened this issue Mar 14, 2024 · 7 comments · May be fixed by #51
Closed

TypeError: eval() got an unexpected keyword argument 'net_avg' #50

LeungKamdayjat opened this issue Mar 14, 2024 · 7 comments · May be fixed by #51

Comments

@LeungKamdayjat
Copy link

LeungKamdayjat commented Mar 14, 2024

Hi, I installed cellpose-napari plugin in naparim, when I tried to run segment, this happened. I don't think there's a way for me to change net_ave since I only have the true/false options in the GUI interface.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File /opt/homebrew/anaconda3/envs/napari/lib/python3.9/site-packages/superqt/utils/_qthreading.py:617, in create_worker.<locals>.reraise(e=TypeError("eval() got an unexpected keyword argument 'net_avg'"))
    616 def reraise(e):
--> 617     raise e
        e = TypeError("eval() got an unexpected keyword argument 'net_avg'")

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

File /opt/homebrew/anaconda3/envs/napari/lib/python3.9/site-packages/superqt/utils/_qthreading.py:357, in FunctionWorker.work(self=<napari._qt.qthreading.FunctionWorker object>)
    356 def work(self) -> _R:
--> 357     return self._func(*self._args, **self._kwargs)
        self._func = <function widget_wrapper.<locals>.run_cellpose at 0x291a02d30>
        self = <napari._qt.qthreading.FunctionWorker object at 0x16ba32af0>
        self._args = ()
        self._kwargs = {'image': <class 'numpy.ndarray'> (934, 934) uint16, 'model_type': 'cyto', 'custom_model': '/Users/jeffrey.liang', 'channels': [1, 0], 'channel_axis': None, 'diameter': 5.64, 'net_avg': False, 'resample': False, 'cellprob_threshold': 1.747126, 'model_match_threshold': 25.0, 'do_3D': False, 'stitch_threshold': 0.0}

File /opt/homebrew/anaconda3/envs/napari/lib/python3.9/site-packages/torch/utils/_contextlib.py:115, in context_decorator.<locals>.decorate_context(*args=(), **kwargs={'cellprob_threshold': 1.747126, 'channel_axis': None, 'channels': [1, 0], 'custom_model': '/Users/jeffrey.liang', 'diameter': 5.64, 'do_3D': False, 'image': <class 'numpy.ndarray'> (934, 934) uint16, 'model_match_threshold': 25.0, 'model_type': 'cyto', 'net_avg': False, ...})
    112 @functools.wraps(func)
    113 def decorate_context(*args, **kwargs):
    114     with ctx_factory():
--> 115         return func(*args, **kwargs)
        func = <function widget_wrapper.<locals>.run_cellpose at 0x1687939d0>
        args = ()
        kwargs = {'image': <class 'numpy.ndarray'> (934, 934) uint16, 'model_type': 'cyto', 'custom_model': '/Users/jeffrey.liang', 'channels': [1, 0], 'channel_axis': None, 'diameter': 5.64, 'net_avg': False, 'resample': False, 'cellprob_threshold': 1.747126, 'model_match_threshold': 25.0, 'do_3D': False, 'stitch_threshold': 0.0}

File /opt/homebrew/anaconda3/envs/napari/lib/python3.9/site-packages/cellpose_napari/_dock_widget.py:73, in widget_wrapper.<locals>.run_cellpose(image=<class 'numpy.ndarray'> (934, 934) uint16, model_type='cyto', custom_model='/Users/jeffrey.liang', channels=[1, 0], channel_axis=None, diameter=5.64, net_avg=False, resample=False, cellprob_threshold=1.747126, model_match_threshold=25.0, do_3D=False, stitch_threshold=0.0)
     71 else:
     72     CP = models.CellposeModel(model_type=model_type, gpu=True)
---> 73 masks, flows_orig, _ = CP.eval(image, 
        CP = <cellpose.models.CellposeModel object at 0x2bcf3c250>
        image = <class 'numpy.ndarray'> (934, 934) uint16
        channels = [1, 0]
        channel_axis = None
        diameter = 5.64
        net_avg = False
        resample = False
        cellprob_threshold = 1.747126
        flow_threshold = 0.6
        do_3D = False
        stitch_threshold = 0.0
     74                             channels=channels, 
     75                             channel_axis=channel_axis,
     76                             diameter=diameter,
     77                             net_avg=net_avg,
     78                             resample=resample,
     79                             cellprob_threshold=cellprob_threshold,
     80                             flow_threshold=flow_threshold,
     81                             do_3D=do_3D,
     82                             stitch_threshold=stitch_threshold)
     83 del CP
     84 if not do_3D and stitch_threshold==0 and masks.ndim > 2:

TypeError: eval() got an unexpected keyword argument 'net_avg'
@kelk16
Copy link

kelk16 commented Mar 29, 2024

I had the same issue, which I was able to solve by making a new environment using cellpose v2.3.2 instead of v3.0.7, which I had been using. Hope this helps!

@psobolewskiPhD
Copy link
Contributor

I can confirm both the error and the workaround -- looks like the plugin needs to be updated for the latest cellpose release

@jo-mueller
Copy link

Hi @psobolewskiPhD ,

do you know who is maintaining the plugin? I sent a PR (#51 ) to fix the problem but it looks like nobody is taking a look :/

Best, Johannes

@psobolewskiPhD
Copy link
Contributor

Sorry I don't -- for a bit Talley was merging some PR...
Maybe we try ping to @carsen-stringer and see what the plan is for this repo.

@jo-mueller
Copy link

@psobolewskiPhD I already tried that above and didn't get a reply. Maybe @tlambert03 knows who else has maintainer access to this repository and may be inclined to merge fixes?

@keesh0
Copy link

keesh0 commented Jun 13, 2024

Yes, I had to downgrade CellPose via
pip install cellpose==2.2.3.
The old default was net_avg=False, so maybe I can update my code to be future proof?
model.eval(gray, diameter=average_diameter_pixs, channels=channels, net_avg=False, augment=True)

@carsen-stringer
Copy link
Member

sorry for the delay this is fixed now

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

Successfully merging a pull request may close this issue.

6 participants