volume-em / empanada-napari

Panoptic segmentation algorithms for 2D and 3D electron microscopy in napari
https://empanada.readthedocs.io/en/latest/empanada-napari.html
BSD 3-Clause "New" or "Revised" License
20 stars 8 forks source link

Opening the plugin fails with error #19

Closed constantinpape closed 2 years ago

constantinpape commented 2 years ago

Trying to open any of the plugins distributed via empanada-napari, e.g. 2D Inference fails with an error for me (extremely long traceback, so at the end of the issue). I have installed the plugin in a clean conda environment with the latest napari, here's the full napari info

napari: 0.4.16
Platform: Linux-5.14.0-1044-oem-x86_64-with-glibc2.31
System: Ubuntu 20.04.4 LTS
Python: 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 07:06:46) [GCC 10.3.0]
Qt: 5.12.9
PyQt5: 5.12.3
NumPy: 1.22.4
SciPy: 1.8.1
Dask: 2022.7.0
VisPy: 0.10.0

OpenGL:
- GL version: 4.6 (Compatibility Profile) Mesa 21.2.6
- MAX_TEXTURE_SIZE: 16384

Screens:
- screen 1: resolution 1920x1200, scale 1.0
- screen 2: resolution 1920x1080, scale 1.0

Plugins:
- console: 0.0.4
- empanada-napari: 0.2.0
- napari-svg: 0.1.6
- scikit-image: 0.4.16
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/napari/_qt/menus/plugins_menu.py:97, in PluginsMenu._add_plugin_actions.<locals>._add_toggle_widget(key=('empanada-napari', '3D Inference'), hook_type='dock')
     94     return
     96 if hook_type == 'dock':
---> 97     self._win.add_plugin_dock_widget(*key)
        key = ('empanada-napari', '3D Inference')
        self._win = <napari._qt.qt_main_window.Window object at 0x7fe0c4ae9ea0>
        self = <napari._qt.menus.plugins_menu.PluginsMenu object at 0x7fe08fa34c10>
     98 else:
     99     self._win._add_plugin_function_widget(*key)

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/napari/_qt/qt_main_window.py:699, in Window.add_plugin_dock_widget(self=<napari._qt.qt_main_window.Window object>, plugin_name='empanada-napari', widget_name='3D Inference')
    696         wdg = wdg._magic_widget
    697     return dock_widget, wdg
--> 699 wdg = _instantiate_dock_widget(Widget, self._qt_viewer.viewer)
        Widget = <function volume_inference_widget at 0x7fe0a57a20e0>
        self = <napari._qt.qt_main_window.Window object at 0x7fe0c4ae9ea0>
    701 # Add dock widget
    702 dock_kwargs.pop('name', None)

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/napari/_qt/qt_main_window.py:1301, in _instantiate_dock_widget(wdg_cls=<function volume_inference_widget>, viewer=Viewer(axes=Axes(visible=False, labels=True, col...ings._transform_active_layer at 0x7fe0905ba290>}))
   1296             break
   1297         # cannot look for param.kind == param.VAR_KEYWORD because
   1298         # QWidget allows **kwargs but errs on unknown keyword arguments
   1299 
   1300 # instantiate the widget
-> 1301 return wdg_cls(**kwargs)
        kwargs = {}
        wdg_cls = <function volume_inference_widget at 0x7fe0a57a20e0>

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/empanada_napari/_volume_inference.py:87, in volume_inference_widget()
     52         yield stack, axis_name
     54     return trackers_dict
     56 @magicgui(
     57     label_head=dict(widget_type='Label', label=f'<h1 style="text-align:center"><img src="{logo}"></h1>'),
     58     call_button='Run 3D Inference',
     59     layout='vertical',
     60     model_config=dict(widget_type='ComboBox', label='model', choices=list(model_configs.keys()), value=list(model_configs.keys())[0], tooltip='Model to use for inference'),
     61     store_dir=dict(widget_type='FileEdit', value='no zarr storage', label='Zarr Directory (optional)', mode='d', tooltip='location to store segmentations on disk'),
     62     use_gpu=dict(widget_type='CheckBox', text='Use GPU', value=device_count() >= 1, tooltip='If checked, run on GPU 0'),
     63     use_quantized=dict(widget_type='CheckBox', text='Use quantized model', value=device_count() == 0, tooltip='If checked, use the quantized model for faster CPU inference.'),
     64     multigpu=dict(widget_type='CheckBox', text='Multi GPU', value=False, tooltip='If checked, run on all available GPUs'),
     65 
     66     parameters2d_head=dict(widget_type='Label', label=f'<h3 text-align="center">2D Parameters</h3>'),
     67     downsampling=dict(widget_type='ComboBox', choices=[1, 2, 4, 8, 16, 32, 64], value=1, label='Image Downsampling', tooltip='Downsampling factor to apply before inference'),
     68     confidence_thr=dict(widget_type='FloatSpinBox', value=0.5, min=0.1, max=0.9, step=0.1, label='Segmentation Confidence Thr'),
     69     center_confidence_thr=dict(widget_type='FloatSpinBox', value=0.1, min=0.05, max=0.9, step=0.05, label='Center Confidence Thr'),
     70     min_distance_object_centers=dict(widget_type='SpinBox', value=3, min=1, max=21, step=1, label='Centers Min Distance'),
     71     fine_boundaries=dict(widget_type='CheckBox', text='Fine Boundaries', value=False, tooltip='Finer boundaries between objects'),
     72     semantic_only=dict(widget_type='CheckBox', text='Semantic Only', value=False, tooltip='Only run semantic segmentation for all classes.'),
     73 
     74     parameters_stack_head=dict(widget_type='Label', label=f'<h3 text-align="center">Stack Parameters</h3>'),
     75     median_slices=dict(widget_type='ComboBox', choices=[1, 3, 5, 7, 9, 11], value=3, label='Median Filter Size', tooltip='Median filter size'),
     76     min_size=dict(widget_type='SpinBox', value=500, min=0, max=1e6, step=100, label='Min Size (Voxels)'),
     77     min_extent=dict(widget_type='SpinBox', value=5, min=0, max=1000, step=1, label='Min Box Extent'),
     78     maximum_objects_per_class=dict(widget_type='LineEdit', value='1000000', label='Max objects per class in 3D'),
     79     inference_plane=dict(widget_type='ComboBox', choices=['xy', 'xz', 'yz'], value='xy', label='Inference plane', tooltip='Image plane along which to run inference. Overwritten, if using ortho-plane.'),
     80 
     81     parameters_ortho_head=dict(widget_type='Label', label=f'<h3 text-align="center">Ortho-plane Parameters (Optional)</h3>'),
     82     orthoplane=dict(widget_type='CheckBox', text='Run ortho-plane', value=False, tooltip='Whether to run orthoplane inference'),
     83     return_panoptic=dict(widget_type='CheckBox', text='Return xy, xz, yz stacks', value=False, tooltip='Whether to return the inference stacks.'),
     84     pixel_vote_thr=dict(widget_type='SpinBox', value=2, min=1, max=3, step=1, label='Voxel Vote Thr Out of 3', tooltip='Number of votes out of 3 for a voxel to be labeled in the consensus'),
     85     allow_one_view=dict(widget_type='CheckBox', text='Permit detections found in 1 stack into consensus', value=False, tooltip='Whether to allow detections into consensus that were picked up by inference in just 1 stack')
     86 )
---> 87 def widget(
        model_configs = {'MitoNet_v1_mini': '/home/pape/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/empanada_napari/configs/MitoNet_v1_mini.yaml', 'MitoNet_v1': '/home/pape/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/empanada_napari/configs/MitoNet_v1.yaml'}
        napari.viewer.Viewer = <class 'napari.viewer.Viewer'>
        napari.viewer = <module 'napari.viewer' from '/home/pape/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/napari/viewer.py'>
        Image = <class 'napari.layers.image.image.Image'>
     88     viewer: napari.viewer.Viewer,
     89     label_head,
     90     image_layer: Image,
     91     model_config,
     92     store_dir,
     93     use_gpu,
     94     use_quantized,
     95     multigpu,
     96 
     97     parameters2d_head,
     98     downsampling,
     99     confidence_thr,
    100     center_confidence_thr,
    101     min_distance_object_centers,
    102     fine_boundaries,
    103     semantic_only,
    104 
    105     parameters_stack_head,
    106     median_slices,
    107     min_size,
    108     min_extent,
    109     maximum_objects_per_class,
    110     inference_plane,
    111 
    112     parameters_ortho_head,
    113     orthoplane,
    114     return_panoptic,
    115     pixel_vote_thr,
    116     allow_one_view
    117 ):
    118     # load the model config
    119     model_config_name = model_config
    120     model_config = read_yaml(model_configs[model_config])

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/_magicgui.py:246, in _magicgui.<locals>.inner_func(func=<function volume_inference_widget.<locals>.widget>)
    241     return MagicFactory(
    242         func, magic_class=magic_class, widget_init=widget_init, **kwargs
    243     )
    244 # MagicFactory is unnecessary if we are immediately instantiating the widget,
    245 # so we shortcut that and just return the FunctionGui here.
--> 246 return magic_class(func, **kwargs)
        magic_class = <class 'magicgui.widgets._function_gui.FunctionGui'>
        func = <function volume_inference_widget.<locals>.widget at 0x7fe024766b00>
        kwargs = {'layout': 'vertical', 'scrollable': False, 'labels': True, 'tooltips': True, 'call_button': 'Run 3D Inference', 'auto_call': False, 'result_widget': False, 'app': None, 'persist': False, 'param_options': {'label_head': {'widget_type': 'Label', 'label': '<h1 style="text-align:center"><img src="/home/pape/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/empanada_napari/resources/empanada_logo.png"></h1>'}, 'model_config': {'widget_type': 'ComboBox', 'label': 'model', 'choices': ['MitoNet_v1_mini', 'MitoNet_v1'], 'value': 'MitoNet_v1_mini', 'tooltip': 'Model to use for inference'}, 'store_dir': {'widget_type': 'FileEdit', 'value': 'no zarr storage', 'label': 'Zarr Directory (optional)', 'mode': 'd', 'tooltip': 'location to store segmentations on disk'}, 'use_gpu': {'widget_type': 'CheckBox', 'text': 'Use GPU', 'value': False, 'tooltip': 'If checked, run on GPU 0'}, 'use_quantized': {'widget_type': 'CheckBox', 'text': 'Use quantized model', 'value': True, 'tooltip': 'If checked, use the quantized model for faster CPU inference.'}, 'multigpu': {'widget_type': 'CheckBox', 'text': 'Multi GPU', 'value': False, 'tooltip': 'If checked, run on all available GPUs'}, 'parameters2d_head': {'widget_type': 'Label', 'label': '<h3 text-align="center">2D Parameters</h3>'}, 'downsampling': {'widget_type': 'ComboBox', 'choices': [1, 2, 4, 8, 16, 32, 64], 'value': 1, 'label': 'Image Downsampling', 'tooltip': 'Downsampling factor to apply before inference'}, 'confidence_thr': {'widget_type': 'FloatSpinBox', 'value': 0.5, 'min': 0.1, 'max': 0.9, 'step': 0.1, 'label': 'Segmentation Confidence Thr'}, 'center_confidence_thr': {'widget_type': 'FloatSpinBox', 'value': 0.1, 'min': 0.05, 'max': 0.9, 'step': 0.05, 'label': 'Center Confidence Thr'}, 'min_distance_object_centers': {'widget_type': 'SpinBox', 'value': 3, 'min': 1, 'max': 21, 'step': 1, 'label': 'Centers Min Distance'}, 'fine_boundaries': {'widget_type': 'CheckBox', 'text': 'Fine Boundaries', 'value': False, 'tooltip': 'Finer boundaries between objects'}, 'semantic_only': {'widget_type': 'CheckBox', 'text': 'Semantic Only', 'value': False, 'tooltip': 'Only run semantic segmentation for all classes.'}, 'parameters_stack_head': {'widget_type': 'Label', 'label': '<h3 text-align="center">Stack Parameters</h3>'}, 'median_slices': {'widget_type': 'ComboBox', 'choices': [1, 3, 5, 7, 9, 11], 'value': 3, 'label': 'Median Filter Size', 'tooltip': 'Median filter size'}, 'min_size': {'widget_type': 'SpinBox', 'value': 500, 'min': 0, 'max': 1000000.0, 'step': 100, 'label': 'Min Size (Voxels)'}, 'min_extent': {'widget_type': 'SpinBox', 'value': 5, 'min': 0, 'max': 1000, 'step': 1, 'label': 'Min Box Extent'}, 'maximum_objects_per_class': {'widget_type': 'LineEdit', 'value': '1000000', 'label': 'Max objects per class in 3D'}, 'inference_plane': {'widget_type': 'ComboBox', 'choices': ['xy', 'xz', 'yz'], 'value': 'xy', 'label': 'Inference plane', 'tooltip': 'Image plane along which to run inference. Overwritten, if using ortho-plane.'}, 'parameters_ortho_head': {'widget_type': 'Label', 'label': '<h3 text-align="center">Ortho-plane Parameters (Optional)</h3>'}, 'orthoplane': {'widget_type': 'CheckBox', 'text': 'Run ortho-plane', 'value': False, 'tooltip': 'Whether to run orthoplane inference'}, 'return_panoptic': {'widget_type': 'CheckBox', 'text': 'Return xy, xz, yz stacks', 'value': False, 'tooltip': 'Whether to return the inference stacks.'}, 'pixel_vote_thr': {'widget_type': 'SpinBox', 'value': 2, 'min': 1, 'max': 3, 'step': 1, 'label': 'Voxel Vote Thr Out of 3', 'tooltip': 'Number of votes out of 3 for a voxel to be labeled in the consensus'}, 'allow_one_view': {'widget_type': 'CheckBox', 'text': 'Permit detections found in 1 stack into consensus', 'value': False, 'tooltip': 'Whether to allow detections into consensus that were picked up by inference in just 1 stack'}}}

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_function_gui.py:176, in FunctionGui.__init__(self=<FunctionGui widget(viewer: napari.viewer.Viewer...c=False, pixel_vote_thr=2, allow_one_view=False)>, function=<function volume_inference_widget.<locals>.widget>, call_button='Run 3D Inference', layout='vertical', scrollable=False, labels=True, tooltips=True, app=None, visible=None, auto_call=False, result_widget=False, param_options={'allow_one_view': {'text': 'Permit detections found in 1 stack into consensus', 'tooltip': 'Whether to allow detections into consensus that were picked up by inference in just 1 stack', 'value': False, 'widget_type': 'CheckBox'}, 'center_confidence_thr': {'label': 'Center Confidence Thr', 'max': 0.9, 'min': 0.05, 'step': 0.05, 'value': 0.1, 'widget_type': 'FloatSpinBox'}, 'confidence_thr': {'label': 'Segmentation Confidence Thr', 'max': 0.9, 'min': 0.1, 'step': 0.1, 'value': 0.5, 'widget_type': 'FloatSpinBox'}, 'downsampling': {'choices': [1, 2, 4, 8, 16, 32, 64], 'label': 'Image Downsampling', 'tooltip': 'Downsampling factor to apply before inference', 'value': 1, 'widget_type': 'ComboBox'}, 'fine_boundaries': {'text': 'Fine Boundaries', 'tooltip': 'Finer boundaries between objects', 'value': False, 'widget_type': 'CheckBox'}, 'inference_plane': {'choices': ['xy', 'xz', 'yz'], 'label': 'Inference plane', 'tooltip': 'Image plane along which to run inference. Overwritten, if using ortho-plane.', 'value': 'xy', 'widget_type': 'ComboBox'}, 'label_head': {'label': '<h1 style="text-align:center"><img src="/home/pa...mpanada_napari/resources/empanada_logo.png"></h1>', 'widget_type': 'Label'}, 'maximum_objects_per_class': {'label': 'Max objects per class in 3D', 'value': '1000000', 'widget_type': 'LineEdit'}, 'median_slices': {'choices': [1, 3, 5, 7, 9, 11], 'label': 'Median Filter Size', 'tooltip': 'Median filter size', 'value': 3, 'widget_type': 'ComboBox'}, 'min_distance_object_centers': {'label': 'Centers Min Distance', 'max': 21, 'min': 1, 'step': 1, 'value': 3, 'widget_type': 'SpinBox'}, ...}, name='widget', persist=False, **kwargs={})
    173         name = f"{function.__module__}.{function.__class__}"
    174 self._callable_name = name
--> 176 super().__init__(
        layout = 'vertical'
        scrollable = False
        labels = True
        visible = None
        sig = <MagicSignature (viewer: napari.viewer.Viewer, label_head, image_layer: napari.layers.image.image.Image, model_config, store_dir, use_gpu, use_quantized, multigpu, parameters2d_head, downsampling, confidence_thr, center_confidence_thr, min_distance_object_centers, fine_boundaries, semantic_only, parameters_stack_head, median_slices, min_size, min_extent, maximum_objects_per_class, inference_plane, parameters_ortho_head, orthoplane, return_panoptic, pixel_vote_thr, allow_one_view)>
        app = None
        name = 'widget'
        self._callable_name = 'widget'
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = None, label_head='', image_layer: napari.layers.image.image.Image = None, model_config='MitoNet_v1_mini', store_dir=PosixPath('no zarr storage'), use_gpu=False, use_quantized=True, multigpu=False, parameters2d_head='', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, parameters_stack_head='', median_slices=3, min_size=500, min_extent=5, maximum_objects_per_class='1000000', inference_plane='xy', parameters_ortho_head='', orthoplane=False, return_panoptic=False, pixel_vote_thr=2, allow_one_view=False)>
        name or self._callable_name = 'widget'
    177     layout=layout,
    178     scrollable=scrollable,
    179     labels=labels,
    180     visible=visible,
    181     widgets=list(sig.widgets(app).values()),
    182     name=name or self._callable_name,
    183 )
    184 self._param_options = param_options
    185 self._result_name = ""

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_concrete.py:167, in backend_widget.<locals>.wrapper.<locals>.__init__(self=<FunctionGui widget(viewer: napari.viewer.Viewer...c=False, pixel_vote_thr=2, allow_one_view=False)>, **kwargs={'labels': True, 'layout': 'vertical', 'name': 'widget', 'scrollable': False, 'visible': None, 'widget_type': <class 'magicgui.backends._qtpy.widgets.Container'>, 'widgets': [<EmptyWidget (name='viewer')>, Label(value='', annotation=<class 'inspect._empty'>, name='label_head'), ComboBox(value=None, annotation=<class 'napari.layers.image.image.Image'>, name='image_layer'), ComboBox(value='MitoNet_v1_mini', annotation=<class 'inspect._empty'>, name='model_config'), FileEdit(mode='d', value=PosixPath('no zarr storage')), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='use_gpu'), CheckBox(value=True, annotation=<class 'inspect._empty'>, name='use_quantized'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='multigpu'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters2d_head'), ComboBox(value=1, annotation=<class 'inspect._empty'>, name='downsampling'), FloatSpinBox(value=0.5, annotation=<class 'inspect._empty'>, name='confidence_thr'), FloatSpinBox(value=0.1, annotation=<class 'inspect._empty'>, name='center_confidence_thr'), SpinBox(value=3, annotation=<class 'inspect._empty'>, name='min_distance_object_centers'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='fine_boundaries'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='semantic_only'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters_stack_head'), ComboBox(value=3, annotation=<class 'inspect._empty'>, name='median_slices'), SpinBox(value=500, annotation=<class 'inspect._empty'>, name='min_size'), SpinBox(value=5, annotation=<class 'inspect._empty'>, name='min_extent'), LineEdit(value='1000000', annotation=<class 'inspect._empty'>, name='maximum_objects_per_class'), ...]})
    165     widget = transform(widget)
    166 kwargs["widget_type"] = widget
--> 167 super(cls, self).__init__(**kwargs)
        kwargs = {'layout': 'vertical', 'scrollable': False, 'labels': True, 'visible': None, 'widgets': [<EmptyWidget (name='viewer')>, Label(value='', annotation=<class 'inspect._empty'>, name='label_head'), ComboBox(value=None, annotation=<class 'napari.layers.image.image.Image'>, name='image_layer'), ComboBox(value='MitoNet_v1_mini', annotation=<class 'inspect._empty'>, name='model_config'), FileEdit(mode='d', value=PosixPath('no zarr storage')), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='use_gpu'), CheckBox(value=True, annotation=<class 'inspect._empty'>, name='use_quantized'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='multigpu'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters2d_head'), ComboBox(value=1, annotation=<class 'inspect._empty'>, name='downsampling'), FloatSpinBox(value=0.5, annotation=<class 'inspect._empty'>, name='confidence_thr'), FloatSpinBox(value=0.1, annotation=<class 'inspect._empty'>, name='center_confidence_thr'), SpinBox(value=3, annotation=<class 'inspect._empty'>, name='min_distance_object_centers'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='fine_boundaries'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='semantic_only'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters_stack_head'), ComboBox(value=3, annotation=<class 'inspect._empty'>, name='median_slices'), SpinBox(value=500, annotation=<class 'inspect._empty'>, name='min_size'), SpinBox(value=5, annotation=<class 'inspect._empty'>, name='min_extent'), LineEdit(value='1000000', annotation=<class 'inspect._empty'>, name='maximum_objects_per_class'), ComboBox(value='xy', annotation=<class 'inspect._empty'>, name='inference_plane'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters_ortho_head'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='orthoplane'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='return_panoptic'), SpinBox(value=2, annotation=<class 'inspect._empty'>, name='pixel_vote_thr'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='allow_one_view')], 'name': 'widget', 'widget_type': <class 'magicgui.backends._qtpy.widgets.Container'>}
        cls = <class 'magicgui.widgets.Container'>
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = None, label_head='', image_layer: napari.layers.image.image.Image = None, model_config='MitoNet_v1_mini', store_dir=PosixPath('no zarr storage'), use_gpu=False, use_quantized=True, multigpu=False, parameters2d_head='', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, parameters_stack_head='', median_slices=3, min_size=500, min_extent=5, maximum_objects_per_class='1000000', inference_plane='xy', parameters_ortho_head='', orthoplane=False, return_panoptic=False, pixel_vote_thr=2, allow_one_view=False)>

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_bases/container_widget.py:81, in ContainerWidget.__init__(self=<FunctionGui widget(viewer: napari.viewer.Viewer...c=False, pixel_vote_thr=2, allow_one_view=False)>, layout='vertical', scrollable=False, widgets=[<EmptyWidget (name='viewer')>, Label(value='', annotation=<class 'inspect._empty'>, name='label_head'), ComboBox(value=None, annotation=<class 'napari.layers.image.image.Image'>, name='image_layer'), ComboBox(value='MitoNet_v1_mini', annotation=<class 'inspect._empty'>, name='model_config'), FileEdit(mode='d', value=PosixPath('no zarr storage')), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='use_gpu'), CheckBox(value=True, annotation=<class 'inspect._empty'>, name='use_quantized'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='multigpu'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters2d_head'), ComboBox(value=1, annotation=<class 'inspect._empty'>, name='downsampling'), FloatSpinBox(value=0.5, annotation=<class 'inspect._empty'>, name='confidence_thr'), FloatSpinBox(value=0.1, annotation=<class 'inspect._empty'>, name='center_confidence_thr'), SpinBox(value=3, annotation=<class 'inspect._empty'>, name='min_distance_object_centers'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='fine_boundaries'), CheckBox(value=False, annotation=<class 'inspect._empty'>, name='semantic_only'), Label(value='', annotation=<class 'inspect._empty'>, name='parameters_stack_head'), ComboBox(value=3, annotation=<class 'inspect._empty'>, name='median_slices'), SpinBox(value=500, annotation=<class 'inspect._empty'>, name='min_size'), SpinBox(value=5, annotation=<class 'inspect._empty'>, name='min_extent'), LineEdit(value='1000000', annotation=<class 'inspect._empty'>, name='maximum_objects_per_class'), ...], labels=True, **kwargs={'backend_kwargs': {'layout': 'vertical', 'scrollable': False}, 'name': 'widget', 'visible': None, 'widget_type': <class 'magicgui.backends._qtpy.widgets.Container'>})
     79 self.parent_changed.connect(self.reset_choices)
     80 self._initialized = True
---> 81 self._unify_label_widths()
        self = <FunctionGui widget(viewer: napari.viewer.Viewer = None, label_head='', image_layer: napari.layers.image.image.Image = None, model_config='MitoNet_v1_mini', store_dir=PosixPath('no zarr storage'), use_gpu=False, use_quantized=True, multigpu=False, parameters2d_head='', downsampling=1, confidence_thr=0.5, center_confidence_thr=0.1, min_distance_object_centers=3, fine_boundaries=False, semantic_only=False, parameters_stack_head='', median_slices=3, min_size=500, min_extent=5, maximum_objects_per_class='1000000', inference_plane='xy', parameters_ortho_head='', orthoplane=False, return_panoptic=False, pixel_vote_thr=2, allow_one_view=False)>

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_bases/container_widget.py:200, in ContainerWidget._unify_label_widths(self=<FunctionGui widget(viewer: napari.viewer.Viewer...c=False, pixel_vote_thr=2, allow_one_view=False)>)
    198 labeled_widget = w._labeled_widget()
    199 if labeled_widget:
--> 200     labeled_widget.label_width = widest_label
        widest_label = 283.671875
        labeled_widget = Labeled<EmptyWidget (name='viewer')>

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_bases/container_widget.py:100, in ContainerWidget.__setattr__(self=Labeled<EmptyWidget (name='viewer')>, name='label_width', value=283.671875)
     94         if name == widget.name:
     95             raise AttributeError(
     96                 "Cannot set attribute with same name as a widget\n"
     97                 "If you are trying to change the value of a widget, use: "
     98                 f"`{self.__class__.__name__}.{name}.value = {value}`",
     99             )
--> 100 object.__setattr__(self, name, value)
        self = Labeled<EmptyWidget (name='viewer')>
        name = 'label_width'
        value = 283.671875

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_concrete.py:1024, in _LabeledWidget.label_width(self=Labeled<EmptyWidget (name='viewer')>, width=283.671875)
   1022 @label_width.setter
   1023 def label_width(self, width):
-> 1024     self._label_widget.min_width = width
        width = 283.671875
        self._label_widget = Label(value='viewer', annotation=None, name='')
        self = Labeled<EmptyWidget (name='viewer')>

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/widgets/_bases/widget.py:208, in Widget.min_width(self=Label(value='viewer', annotation=None, name=''), value=283.671875)
    205 @min_width.setter
    206 def min_width(self, value: int) -> None:
    207     """Set the minimum width of the widget."""
--> 208     self._widget._mgui_set_min_width(value)
        value = 283.671875
        self._widget = <magicgui.backends._qtpy.widgets.Label object at 0x7fe0245f59f0>
        self = Label(value='viewer', annotation=None, name='')

File ~/software/conda/miniconda3/envs/mitonet/lib/python3.10/site-packages/magicgui/backends/_qtpy/widgets.py:101, in QBaseWidget._mgui_set_min_width(self=<magicgui.backends._qtpy.widgets.Label object>, value=283.671875)
     99 def _mgui_set_min_width(self, value: int) -> None:
    100     """Set the minimum allowable width of the widget."""
--> 101     self._qwidget.setMinimumWidth(value)
        value = 283.671875
        self._qwidget = <PyQt5.QtWidgets.QLabel object at 0x7fe0247472e0>
        self = <magicgui.backends._qtpy.widgets.Label object at 0x7fe0245f59f0>
    102     self._qwidget.resize(self._qwidget.sizeHint())

TypeError: setMinimumWidth(self, int): argument 1 has unexpected type 'float'
conradry commented 2 years ago

Hi Constantin,

I reproduced the error by creating the environment with Python 3.10; everything works fine with 3.9 though. There's a note in the installation docs that says 3.10 isn't supported. Originally, I put it there because PyTorch wouldn't install with 3.10. That appears to be fixed with the newest version, but now you've discovered another reason not to use 3.10!

This appears to be a magicgui issue (I'll reach out to them to get it fixed). Apparently, there's some change in Python 3.10 that affects how floats and ints are handled.

constantinpape commented 2 years ago

Hi Ryan, thanks for the quick response, it works with 3.9 now!