Skip to content

Error when segmenting #36

@joaomamede

Description

@joaomamede

Hi, first use resulted in errors.
Can anyone point me to a fix?

Segmenting...
ERROR:root:Unhandled exception:
Traceback (most recent call last):
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/magicgui/core.py", line 199, in <lambda>
    self.call_button.clicked.connect(lambda checked: self.__call__())
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/magicgui/core.py", line 532, in __call__
    value = self.func(**_kwargs)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/gui.py", line 29, in segmentation
    clf, features = fit(data, initial_labels.data, featurizer=featurizer.value)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/semantic/main.py", line 129, in fit
    padded_features = unet_featurize(padded_image, featurizer)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/semantic/main.py", line 59, in unet_featurize
    features = model(image)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/model/unet.py", line 57, in forward
    x = self.decode_4(x, skip_4)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/torch/nn/modules/module.py", line 722, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/jmamede/anaconda3/lib/python3.8/site-packages/segmentify-0.1.1-py3.8.egg/segmentify/model/layers/unet_layers.py", line 63, in forward
    output += skip
RuntimeError: The size of tensor a (254) must match the size of tensor b (255) at non-singleton dimension 2

These were the labels I made before:
image

Same error example:
image

I started things with:

    import napari 
    from segmentify import segmentation 

    with napari.gui_qt(): 
        viewer = napari.Viewer() 
    
        # instantiate the segmentify widget 
        gui = segmentation.Gui() 

        # add the new widget to the napari viewer 
        viewer.window.add_dock_widget(gui) 
 
        # keep the dropdown menus in the gui in sync with the layer model 
        viewer.layers.events.changed.connect(lambda x: gui.refresh_choices() )
                                                                `

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions