bowang-lab / MedSAM

Segment Anything in Medical Images
https://www.nature.com/articles/s41467-024-44824-z
Apache License 2.0
3.03k stars 419 forks source link

segment failure #314

Closed Franktanshuai closed 2 months ago

Franktanshuai commented 2 months ago

Calculating embedding, gui may be unresponsive. Traceback (most recent call last): File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\gui.py", line 323, in w = Window() File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\gui.py", line 148, in init pixmap = self.load_image() File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\gui.py", line 208, in load_image self.get_embeddings() File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\utils_contextlib.py", line 116, in decorate_context return func(*args, kwargs) File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\gui.py", line 315, in get_embeddings self.embedding = medsam_model.image_encoder( File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl return forward_call(args, kwargs) File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\segment_anything\modeling\image_encoder.py", line 110, in forward x = self.patch_embed(x) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\Administrator\Desktop\MedSAM-1.0.0\segment_anything\modeling\image_encoder.py", line 417, in forward x = self.proj(x) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1553, in _wrapped_call_impl return self._call_impl(args, kwargs) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\module.py", line 1562, in _call_impl return forward_call(*args, **kwargs) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\conv.py", line 458, in forward return self._conv_forward(input, self.weight, self.bias) File "E:\project\miniconda\envs\medsam\lib\site-packages\torch\nn\modules\conv.py", line 454, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Given groups=1, weight of size [768, 3, 16, 16], expected input[1, 4, 1024, 1024] to have 3 channels, but got 4 channels instead

I try to segment the picture but failed 1

Franktanshuai commented 2 months ago

when load the picture, it failed

JunMa11 commented 2 months ago

hi @Franktanshuai ,

could you please print the input shape of the image?