bowang-lab / MedSAMSlicer

3D Slicer Plugin for Segment anything in medical images
https://www.nature.com/articles/s41467-024-44824-z
175 stars 20 forks source link

MedSAM_Interface undefined #34

Closed jscott-gauss closed 2 months ago

jscott-gauss commented 3 months ago

Hi there! I'm looking into trying this out and running into a few issues. Are the previous versions more stable? It looks like development is pretty active. If so, please let me know which to use.

System Info

Send Image Error After clicking send image I get the following:

Traceback (most recent call last):
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 241, in <lambda>
    self.ui.pbSendImage.connect('clicked(bool)', lambda: self.logic.sendImage(partial=False))
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 641, in sendImage
    self.run_server()
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 605, in run_server
    self.backend = MedSAM_Interface()
NameError: name 'MedSAM_Interface' is not defined

Looks like you're in the middle of some changes here: https://github.com/bowang-lab/MedSAMSlicer/blob/3f0abf61becfb8958fb33fa4896dd0ce8a4fb4af/MedSAM/MedSAMLite/MedSAMLite.py#L35

since if the import fails, the interface is still accessed: https://github.com/bowang-lab/MedSAMSlicer/blob/3f0abf61becfb8958fb33fa4896dd0ce8a4fb4af/MedSAM/MedSAMLite/MedSAMLite.py#L605

I saw in a previous version that you need to spin up a server that images get sent to, is this something that still needs to be done? I see all the documentation for it is no longer in the readme.

Hardcoded Files

When I try the Reload and Test functionality, it uses a hardcoded filepath on your comp unit /home/rasakereh/Desktop/wanglab/MedSam/slicer-plugin/MedSAM-Slicer/HCC_004_0000.nii.gz

Replacing the filepath and trying again yields:

Traceback (most recent call last):
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/util.py", line 3255, in tryWithErrorDisplay
    yield
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/ScriptedLoadableModule.py", line 265, in onReloadAndTest
    test(msec=int(slicer.app.userSettings().value("Developer/SelfTestDisplayMessageDelay")), **kwargs)
  File "/Applications/Slicer.app/Contents/bin/Python/slicer/ScriptedLoadableModule.py", line 83, in runTest
    testCase.runTest(**kwargs)
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 836, in runTest
    self.test_MedSAMLite1()
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 853, in test_MedSAMLite1
    logic.sendImage()
  File "~/MedSAMSlicer-0.1/MedSAM/MedSAMLite/MedSAMLite.py", line 637, in sendImage
    self.widget.ui.pbSegment.setEnabled(False)
AttributeError: 'NoneType' object has no attribute 'ui'

Maybe include a default test image that gets downloaded on initialization from somewhere outside the repo?

yijiyangshoudechugou commented 2 months ago

hi, are you using medsam1 or medsam2. i wonder whether mac(M1) can run the medsam2? best wish for your reply.

rasakereh commented 2 months ago

@jscott-gauss The second and third issue are not disruptive when it comes to the functionality. The third problem is extremely important tho. would you please enter the following line in the slicer python console and share the output? from medsam_interface import MedSAM_Interface

rasakereh commented 2 months ago

@yijiyangshoudechugou AFAIK we need cuda-12 installed so i'm not sure if macbooks are supoorted. if you could find a cuda variant for M1, sam2 should work fine