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

Error when "Run 2D Inference" is clicked #35

Open
ngordon1QO opened this issue Oct 1, 2024 · 0 comments
Open

Error when "Run 2D Inference" is clicked #35

ngordon1QO opened this issue Oct 1, 2024 · 0 comments

Comments

@ngordon1QO
Copy link

🐛 Bug Report

--- Reported issue to napari, they said it's an empanada error. See issue here ---

Using MacBook Air apple M3, conda environment with Python3.9, clicking the "Run 2D Inference" on the empanada plugin widget raises the following error:

RuntimeError                              Traceback (most recent call last)
File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1196, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, args=(False,))
   1195     with Signal._emitting(self):
-> 1196         self._run_emit_loop_inner()
        self = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        self._run_emit_loop_inner = <bound method SignalInstance._run_emit_loop_immediate of <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>>
   1197 except RecursionError as e:

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1225, in SignalInstance._run_emit_loop_immediate(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>)
   1224 for caller in self._slots:
-> 1225     caller.cb(args)
        args = (False,)
        caller = <StrongFunction on magicgui.widgets._function_gui.FunctionGui.__init__.<locals>._disable_button_and_call>

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_weak_callback.py:357, in StrongFunction.cb(self=<StrongFunction on magicgui.widgets._function_gu...onGui.__init__.<locals>._disable_button_and_call>, args=())
    356     args = args[: self._max_args]
--> 357 self._f(*self._args, *args, **self._kwargs)
        args = ()
        self._f = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x336dff3a0>
        self = <StrongFunction on magicgui.widgets._function_gui.FunctionGui.__init__.<locals>._disable_button_and_call>
        self._args = ()
        self._kwargs = {}

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py:228, in FunctionGui.__init__.<locals>._disable_button_and_call()
    227 try:
--> 228     self.__call__()
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
    229 finally:

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py:346, in FunctionGui.__call__(self=<FunctionGui widget(viewer: napari.viewer.Viewer...s 'magicgui.widgets.ProgressBar'>, name='pbar'))>, *args=(), **kwargs={})
    345 with _function_name_pointing_to_widget(self):
--> 346     value = self._function(*bound.args, **bound.kwargs)
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        bound = <BoundArguments (viewer=Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer=<Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer=None, pbar=ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        self._function = <function test_widget.<locals>.widget at 0x336d5fd30>
    348 self._call_count += 1

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/_slice_inference.py:166, in test_widget.<locals>.widget(viewer=Viewer(camera=Camera(center=(0.0, np.float64(204...use_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer=<Image layer 'VG_0141'>, model_config={'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}, 'class_names': {1: 'mito'}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab ...ww.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'labels': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'norms': {'mean': 0.57571, 'std': 0.12765}, 'padding_factor': 16, 'thing_list': [1]}, downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class=10000, tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer=None, pbar=ProgressBar(value=<function match_type.<locals>....ass 'magicgui.widgets.ProgressBar'>, name='pbar'))
    165 if not hasattr(widget, 'engine') or widget.last_config != model_config_name or use_gpu != widget.using_gpu or use_quantized != widget.using_quantized:
--> 166     widget.engine = Engine2d(
        widget = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        model_config = {'class_names': {1: 'mito'}, 'labels': [1], 'thing_list': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'padding_factor': 16, 'norms': {'mean': 0.57571, 'std': 0.12765}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab dataset and is a generalist for mitochondrial segmentation. The underlying architecture is PanopticDeeplab. This model is fairly large but powerful. If GPU memory is a limitation, try using MitoNet_v1_mini instead. Read the preprint: https://www.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}}
        downsampling = 1
        min_distance_object_centers = 3
        center_confidence_thr = 0.1
        confidence_thr = 0.5
        maximum_objects_per_class = 10000
        semantic_only = False
        fine_boundaries = False
        tile_size = 0
        use_gpu = False
        use_quantized = True
    167         model_config,
    168         inference_scale=downsampling,
    169         nms_kernel=min_distance_object_centers,
    170         nms_threshold=center_confidence_thr,
    171         confidence_thr=confidence_thr,
    172         label_divisor=maximum_objects_per_class,
    173         semantic_only=semantic_only,
    174         fine_boundaries=fine_boundaries,
    175         tile_size=tile_size,
    176         use_gpu=use_gpu,
    177         use_quantized=use_quantized
    178     )
    179     widget.last_config = model_config_name

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/inference.py:193, in Engine2d.__init__(self=<empanada_napari.inference.Engine2d object>, model_config={'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}, 'class_names': {1: 'mito'}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab ...ww.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'labels': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'norms': {'mean': 0.57571, 'std': 0.12765}, 'padding_factor': 16, 'thing_list': [1]}, inference_scale=1, label_divisor=10000, nms_threshold=0.1, nms_kernel=3, confidence_thr=0.5, semantic_only=False, fine_boundaries=False, tile_size=0, use_gpu=False, use_quantized=True)
    191     model_url = model_config['model']
--> 193 model = load_model_to_device(model_url, device)
        device = device(type='cpu')
        model_url = 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1'
    194 model = model.to(device)

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/utils.py:66, in load_model_to_device(fpath_or_url='https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', device=device(type='cpu'))
     64         torch.hub.download_url_to_file(fpath_or_url, cached_file, hash_prefix, progress=True)
---> 66     model = torch.jit.load(cached_file, map_location=device)
        cached_file = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'
        torch.jit = <module 'torch.jit' from '/Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/__init__.py'>
        device = device(type='cpu')
     68 return model

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/_serialization.py:163, in load(f='/Users/natangordon/.empanada/MitoNet_v1_quantized.pth', map_location=device(type='cpu'), _extra_files={}, _restore_shapes=False)
    162 if isinstance(f, (str, os.PathLike)):
--> 163     cpp_module = torch._C.import_ir_module(cu, os.fspath(f), map_location, _extra_files, _restore_shapes)  # type: ignore[call-arg]
        map_location = device(type='cpu')
        cu = <torch.jit.CompilationUnit object at 0x16f422f30>
        f = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'
        _extra_files = {}
        torch._C = <module 'torch._C' from '/Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/_C.cpython-39-darwin.so'>
        _restore_shapes = False
    164 else:

RuntimeError: The following operation failed in the TorchScript interpreter.
Traceback of TorchScript, serialized code (most recent call last):
  File "code/__torch__/torch/nn/intrinsic/quantized/modules/conv_relu.py", line 72, in __setstate__
    self.groups = (state)[8]
    self.padding_mode = (state)[9]
    _7 = (self).set_weight_bias((state)[10], (state)[11], )
          ~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    self.scale = (state)[12]
    self.zero_point = (state)[13]
  File "code/__torch__/torch/nn/intrinsic/quantized/modules/conv_relu.py", line 94, in set_weight_bias
      _13 = [_11, _12]
      _14, _15, = dilation
      _16 = ops.quantized.conv2d_prepack(w, b, _10, _13, [_14, _15], groups)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
      self._packed_params = _16
    else:

Traceback of TorchScript, original code (most recent call last):
  File "/data/IASEM/iasemconda/lib/python3.9/site-packages/torch/nn/quantized/modules/conv.py", line 176, in __setstate__
        self.groups = state[8]
        self.padding_mode = state[9]
        self.set_weight_bias(state[10], state[11])
        ~~~~~~~~~~~~~~~~~~~~ <--- HERE
        self.scale = state[12]
        self.zero_point = state[13]
  File "/data/IASEM/iasemconda/lib/python3.9/site-packages/torch/nn/quantized/modules/conv.py", line 401, in set_weight_bias
    def set_weight_bias(self, w: torch.Tensor, b: Optional[torch.Tensor]) -> None:
        if self.padding_mode == 'zeros':
            self._packed_params = torch.ops.quantized.conv2d_prepack(
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
                w, b, self.stride, self.padding, self.dilation, self.groups)
        else:
RuntimeError: Didn't find engine for operation quantized::conv2d_prepack NoQEngine


The above exception was the direct cause of the following exception:

EmitLoopError                             Traceback (most recent call last)
File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/bases/_value_widget.py:71, in ValueWidget._on_value_change(self=PushButton(value=False, annotation=None, name='call_button'), value=False)
     69 if value is self.null_value and not self._nullable:
     70     return
---> 71 self.changed.emit(value)
        value = False
        self.changed = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        self = PushButton(value=False, annotation=None, name='call_button')

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1176, in SignalInstance.emit(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, check_nargs=False, check_types=False, *args=(False,))
   1172     from ._group import EmissionInfo
   1174     SignalInstance._debug_hook(EmissionInfo(self, args))
-> 1176 self._run_emit_loop(args)
        self = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        args = (False,)

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1213, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, args=(False,))
   1205     loop_err = EmitLoopError(
   1206         exc=cb_err,
   1207         signal=self,
   (...)
   1210         emit_queue=self._emit_queue,
   1211     ).with_traceback(cb_err.__traceback__)
   1212     # this comment will show up in the traceback
-> 1213     raise loop_err from cb_err  # emit() call ABOVE || callback error BELOW
        loop_err = EmitLoopError("\n\nWhile emitting signal 'magicgui.widgets.PushButton.changed', a RuntimeError occurred in a callback:\n\n  Signal emitted at: /Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/bases/_value_widget.py:71, in _on_value_change\n    >  self.changed.emit(value)\n\n  Callback error at: /Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/_serialization.py:163, in load\n    >  cpp_module = torch._C.import_ir_module(cu, os.fspath(f), map_location, _extra_files, _restore_shapes)  # type: ignore[call-arg]\n\n    Local variables:\n       f = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'\n       map_location = device(type='cpu')\n       _extra_files = {}\n       _restore_shapes = False\n       cu = <torch.jit.CompilationUnit object at 0x16f422f30>\n\nSee RuntimeError above for original traceback.")
   1214 finally:
   1215     self._recursion_depth -= 1

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1196, in SignalInstance._run_emit_loop(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>, args=(False,))
   1192     self._max_recursion_depth = max(
   1193         self._max_recursion_depth, self._recursion_depth
   1194     )
   1195     with Signal._emitting(self):
-> 1196         self._run_emit_loop_inner()
        self = <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>
        self._run_emit_loop_inner = <bound method SignalInstance._run_emit_loop_immediate of <SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>>
   1197 except RecursionError as e:
   1198     raise RecursionError(
   1199         f"RecursionError when "
   1200         f"emitting signal {self.name!r} with args {args}"
   1201     ) from e

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_signal.py:1225, in SignalInstance._run_emit_loop_immediate(self=<SignalInstance 'changed' on PushButton(value=False, annotation=None, name='call_button')>)
   1223 args = self._emit_queue.popleft()
   1224 for caller in self._slots:
-> 1225     caller.cb(args)
        args = (False,)
        caller = <StrongFunction on magicgui.widgets._function_gui.FunctionGui.__init__.<locals>._disable_button_and_call>

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/psygnal/_weak_callback.py:357, in StrongFunction.cb(self=<StrongFunction on magicgui.widgets._function_gu...onGui.__init__.<locals>._disable_button_and_call>, args=())
    355 if self._max_args is not None:
    356     args = args[: self._max_args]
--> 357 self._f(*self._args, *args, **self._kwargs)
        args = ()
        self._f = <function FunctionGui.__init__.<locals>._disable_button_and_call at 0x336dff3a0>
        self = <StrongFunction on magicgui.widgets._function_gui.FunctionGui.__init__.<locals>._disable_button_and_call>
        self._args = ()
        self._kwargs = {}

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py:228, in FunctionGui.__init__.<locals>._disable_button_and_call()
    226 self._call_button.enabled = False
    227 try:
--> 228     self.__call__()
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
    229 finally:
    230     self._call_button.enabled = True

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/_function_gui.py:346, in FunctionGui.__call__(self=<FunctionGui widget(viewer: napari.viewer.Viewer...s 'magicgui.widgets.ProgressBar'>, name='pbar'))>, *args=(), **kwargs={})
    344 self._tqdm_depth = 0  # reset the tqdm stack count
    345 with _function_name_pointing_to_widget(self):
--> 346     value = self._function(*bound.args, **bound.kwargs)
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        bound = <BoundArguments (viewer=Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer=<Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer=None, pbar=ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        self._function = <function test_widget.<locals>.widget at 0x336d5fd30>
    348 self._call_count += 1
    349 if self._result_widget is not None:

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/_slice_inference.py:166, in test_widget.<locals>.widget(viewer=Viewer(camera=Camera(center=(0.0, np.float64(204...use_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer=<Image layer 'VG_0141'>, model_config={'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}, 'class_names': {1: 'mito'}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab ...ww.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'labels': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'norms': {'mean': 0.57571, 'std': 0.12765}, 'padding_factor': 16, 'thing_list': [1]}, downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class=10000, tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer=None, pbar=ProgressBar(value=<function match_type.<locals>....ass 'magicgui.widgets.ProgressBar'>, name='pbar'))
    163     widget.using_quantized = use_quantized
    165 if not hasattr(widget, 'engine') or widget.last_config != model_config_name or use_gpu != widget.using_gpu or use_quantized != widget.using_quantized:
--> 166     widget.engine = Engine2d(
        widget = <FunctionGui widget(viewer: napari.viewer.Viewer = Viewer(camera=Camera(center=(0.0, np.float64(2047.5), np.float64(2047.5)), zoom=np.float64(0.12820129394531252), angles=(0.0, 0.0, 90.0), perspective=0.0, mouse_pan=True, mouse_zoom=True), cursor=Cursor(position=(np.float64(3814.2529273454825), np.float64(4898.485378934922)), scaled=True, style=<CursorStyle.STANDARD: 'standard'>, size=1.0), dims=Dims(ndim=2, ndisplay=2, order=(0, 1), axis_labels=('0', '1'), rollable=(True, True), range=(RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0)), RangeTuple(start=np.float64(0.0), stop=np.float64(4095.0), step=np.float64(1.0))), margin_left=(0.0, 0.0), margin_right=(0.0, 0.0), point=(np.float64(2047.0), np.float64(2047.0)), last_used=0), grid=GridCanvas(stride=1, shape=(-1, -1), enabled=False), layers=[<Image layer 'VG_0141' at 0x336f27220>], help='use <2> for transform', status='Ready', tooltip=Tooltip(visible=False, text=''), theme='dark', title='napari', mouse_over_canvas=True, mouse_move_callbacks=[], mouse_drag_callbacks=[], mouse_double_click_callbacks=[], mouse_wheel_callbacks=[<function dims_scroll at 0x12f080310>], _persisted_mouse_event={}, _mouse_drag_gen={}, _mouse_wheel_gen={}, _keymap={}), label_head='', image_layer: napari.layers.image.image.Image = <Image layer 'VG_0141' at 0x336f27220>, model_config='MitoNet_v1', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, maximum_objects_per_class='10000', tile_size=0, batch_mode=False, use_gpu=False, use_quantized=True, viewport=False, output_to_layer=False, output_layer: napari.layers.labels.labels.Labels = None, pbar: magicgui.widgets.ProgressBar = ProgressBar(value=<function match_type.<locals>.<lambda> at 0x336dcdc10>, annotation=<class 'magicgui.widgets.ProgressBar'>, name='pbar'))>
        model_config = {'class_names': {1: 'mito'}, 'labels': [1], 'thing_list': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'padding_factor': 16, 'norms': {'mean': 0.57571, 'std': 0.12765}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab dataset and is a generalist for mitochondrial segmentation. The underlying architecture is PanopticDeeplab. This model is fairly large but powerful. If GPU memory is a limitation, try using MitoNet_v1_mini instead. Read the preprint: https://www.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}}
        downsampling = 1
        min_distance_object_centers = 3
        center_confidence_thr = 0.1
        confidence_thr = 0.5
        maximum_objects_per_class = 10000
        semantic_only = False
        fine_boundaries = False
        tile_size = 0
        use_gpu = False
        use_quantized = True
    167         model_config,
    168         inference_scale=downsampling,
    169         nms_kernel=min_distance_object_centers,
    170         nms_threshold=center_confidence_thr,
    171         confidence_thr=confidence_thr,
    172         label_divisor=maximum_objects_per_class,
    173         semantic_only=semantic_only,
    174         fine_boundaries=fine_boundaries,
    175         tile_size=tile_size,
    176         use_gpu=use_gpu,
    177         use_quantized=use_quantized
    178     )
    179     widget.last_config = model_config_name
    180     widget.using_gpu = use_gpu

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/inference.py:193, in Engine2d.__init__(self=<empanada_napari.inference.Engine2d object>, model_config={'FINETUNE': {'criterion': 'PanopticLoss', 'criterion_params': {'ce_weight': 1, 'l1_weight': 0.01, 'mse_weight': 200, 'pr_weight': 1, 'top_k_percent': 0.2}, 'dataset_class': 'SingleClassInstanceDataset', 'dataset_params': {'weight_gamma': 0.7}, 'engine': 'PanopticDeepLabEngine', 'engine_params': {'confidence_thr': 0.5, 'label_divisor': 1000, 'nms_kernel': 7, 'nms_threshold': 0.1, 'stuff_area': 64, 'thing_list': [1], 'void_label': 0}}, 'class_names': {1: 'mito'}, 'description': 'MitoNet_v1 was trained on the large CEM-MitoLab ...ww.biorxiv.org/content/10.1101/2022.03.17.484806\n', 'labels': [1], 'model': 'https://zenodo.org/record/6861565/files/MitoNet_v1.pth?download=1', 'model_quantized': 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', 'norms': {'mean': 0.57571, 'std': 0.12765}, 'padding_factor': 16, 'thing_list': [1]}, inference_scale=1, label_divisor=10000, nms_threshold=0.1, nms_kernel=3, confidence_thr=0.5, semantic_only=False, fine_boundaries=False, tile_size=0, use_gpu=False, use_quantized=True)
    190 else:
    191     model_url = model_config['model']
--> 193 model = load_model_to_device(model_url, device)
        device = device(type='cpu')
        model_url = 'https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1'
    194 model = model.to(device)
    196 self.thing_list = model_config['thing_list']

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/empanada_napari/utils.py:66, in load_model_to_device(fpath_or_url='https://zenodo.org/record/6861565/files/MitoNet_v1_quantized.pth?download=1', device=device(type='cpu'))
     63         hash_prefix = None
     64         torch.hub.download_url_to_file(fpath_or_url, cached_file, hash_prefix, progress=True)
---> 66     model = torch.jit.load(cached_file, map_location=device)
        cached_file = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'
        torch.jit = <module 'torch.jit' from '/Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/__init__.py'>
        device = device(type='cpu')
     68 return model

File ~/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/_serialization.py:163, in load(f='/Users/natangordon/.empanada/MitoNet_v1_quantized.pth', map_location=device(type='cpu'), _extra_files={}, _restore_shapes=False)
    161 cu = torch._C.CompilationUnit()
    162 if isinstance(f, (str, os.PathLike)):
--> 163     cpp_module = torch._C.import_ir_module(cu, os.fspath(f), map_location, _extra_files, _restore_shapes)  # type: ignore[call-arg]
        map_location = device(type='cpu')
        cu = <torch.jit.CompilationUnit object at 0x16f422f30>
        f = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'
        _extra_files = {}
        torch._C = <module 'torch._C' from '/Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/_C.cpython-39-darwin.so'>
        _restore_shapes = False
    164 else:
    165     cpp_module = torch._C.import_ir_module_from_buffer(
    166         cu, f.read(), map_location, _extra_files, _restore_shapes
    167     )  # type: ignore[call-arg]

EmitLoopError: 

While emitting signal 'magicgui.widgets.PushButton.changed', a RuntimeError occurred in a callback:

  Signal emitted at: /Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/magicgui/widgets/bases/_value_widget.py:71, in _on_value_change
    >  self.changed.emit(value)

  Callback error at: /Users/natangordon/miniforge3/envs/napari-cell/lib/python3.9/site-packages/torch/jit/_serialization.py:163, in load
    >  cpp_module = torch._C.import_ir_module(cu, os.fspath(f), map_location, _extra_files, _restore_shapes)  # type: ignore[call-arg]

    Local variables:
       f = '/Users/natangordon/.empanada/MitoNet_v1_quantized.pth'
       map_location = device(type='cpu')
       _extra_files = {}
       _restore_shapes = False
       cu = <torch.jit.CompilationUnit object at 0x16f422f30>

See RuntimeError above for original traceback.

💡 Steps to Reproduce

Click 'Run 2D Inference"

💡 Expected Behavior

No response

🌎 Environment

napari: 0.5.3
Platform: macOS-14.6.1-arm64-arm-64bit
System: MacOS 14.6.1
Python: 3.9.20 | packaged by conda-forge | (main, Sep 22 2024, 14:06:09) [Clang 17.0.6 ]
Qt: 5.15.8
PyQt5: 5.15.9
NumPy: 1.22.0
SciPy: 1.11.4
Dask: 2024.8.0
VisPy: 0.14.3
magicgui: 0.8.3
superqt: 0.6.7
in-n-out: 0.2.1
app-model: 0.2.8
npe2: 0.7.7

OpenGL:

  • GL version: 2.1 Metal - 88.1
  • MAX_TEXTURE_SIZE: 16384
  • GL_MAX_3D_TEXTURE_SIZE: 2048

Screens:

  • screen 1: resolution 1470x956, scale 2.0

Optional:

  • numba: 0.60.0
  • triangle not installed
  • napari-plugin-manager: 0.1.3

Plugins:

  • empanada-napari: 1.1.1 (38 contributions)
  • napari: 0.5.3 (81 contributions)
  • napari-console: 0.0.9 (0 contributions)
  • napari-svg: 0.2.0 (2 contributions)

💡 Additional Context

No response

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

1 participant