computational-cell-analytics / micro-sam

Segment Anything for Microscopy
https://computational-cell-analytics.github.io/micro-sam/
MIT License
336 stars 42 forks source link

using python and 3d image #382

Open Nal44 opened 7 months ago

Nal44 commented 7 months ago

Hi,

I install all using python (3.10)

The widget launch, I select the image (tiff ) 3d, then :

Downloading file 'vit_b_lm' from 'https://zenodo.org/records/10524791/files/vit_b_lm.pth?download=1' to 'C:\Users\m197816\AppData\Local\micro_sam\micro_sam\Cache\models'.
Precompute Image Embeddings: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 27/27 [02:14<00:00,  4.97s/it]
Traceback (most recent call last):
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\window.py", line 14, in <module>
    from napari._qt import Window
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\_qt\__init__.py", line 77, in <module>
    from napari._qt.qt_event_loop import get_app, gui_qt, quit_app, run
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\_qt\qt_event_loop.py", line 15, in <module>
    from napari._qt.dialogs.qt_notification import NapariQtNotification
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\_qt\dialogs\qt_notification.py", line 29, in <module>
    from napari._qt.qt_resources import QColoredSVGIcon
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\_qt\qt_resources\__init__.py", line 4, in <module>
    from napari._qt.qt_resources._svg import QColoredSVGIcon
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\_qt\qt_resources\_svg.py", line 8, in <module>
    from qtpy.QtSvg import QSvgRenderer
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\qtpy\QtSvg.py", line 13, in <module>
    from PyQt5.QtSvg import *
ImportError: DLL load failed while importing QtSvg: The specified procedure could not be found.

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

Traceback (most recent call last):
  File "C:\Users\m197816\.conda\envs\ucrosam38\Scripts\micro_sam.annotator-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\micro_sam\sam_annotator\annotator.py", line 506, in main
    annotator()
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\micro_sam\sam_annotator\annotator.py", line 492, in annotator
    annotator_3d(show_embeddings=False, **config_dict["args"])
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\micro_sam\sam_annotator\annotator_3d.py", line 302, in annotator_3d
    v.window.add_dock_widget(prompt_widget)
  File "C:\Users\m197816\.conda\envs\ucrosam38\lib\site-packages\napari\window.py", line 27, in __getattr__
    raise type(err)(
ImportError: An error occured when importing Qt dependencies.  Cannot show napari window.  See cause above

I remove and reinstalled pyqt but still ... same error .

Any ideas how to solve the problem ?

Thanks,

constantinpape commented 7 months ago

This looks like some windows issue loading the DLLs.

I had a quick look at a related stack overflow: https://stackoverflow.com/questions/42863505/dll-load-failed-when-importing-pyqt5.

From browsing through this:

Nal44 commented 7 months ago

Napari runs when I launched it but the plugin is only available for embeddings (and cache), the dock widgets are not available.

I will reboot in a sec and let you know,

thanks a lot,

constantinpape commented 7 months ago

I would suggest to use the dev branch instead: https://github.com/computational-cell-analytics/micro-sam/tree/dev (Just switch to the branch where you cloned the git repo)

Then the plugins will be available in napari. (We will also release this version soon, but we need to document a bit more before this.)

Nal44 commented 7 months ago

Ok great !

Super helpful :) , looking to use it a lot, especially for 3d nucleus, annotations are a pain and take forever using Labkit ...

My 3d model is pretty good but working to make a refined model, hence the idea to run inferences using my model then using your plugin for refinements, then training a refined model (if metrics are good) .

That will save me a lotttttttttttttttttttttttttttttttttttttt of time :) thanks antho

Nal44 commented 7 months ago

I reboot my machine ,Error is gone :)

But using the point_prompts in 3d the automatic segmentation outputs are not great ... Need to play around and understand how things work.

Thanks a lot :)

Nal44 commented 7 months ago

To give you an idea using positive / negative prompts with the initial parameters

thanks

example

Nal44 commented 7 months ago

Thinking, do images needs any pre -filters ? something to normalize the images or else ? I have the same using a 2d image ... (DAPI staining) ? Thanks

GenevieveBuckley commented 7 months ago

I've always had better results with the box prompts, than the point prompts. Maybe you could try that?

constantinpape commented 7 months ago

To give you an idea using positive / negative prompts with the initial parameters

These are way too many points. You need to give point prompts object by object when you use the annotator. Please watch the video for seeing how to use it: https://www.youtube.com/watch?v=ket7bDUP9tI&list=PLwYZXQJ3f36GQPpKCrSbHjGiH39X4XjSO&index=1

(And if you want to segment multiple objects at a time you can use box prompts, it's also shown in the video)

Nal44 commented 7 months ago

Ok thanks,

Seems ok in 3D, but the masks diffuse too much on the out of focus (mask are getting larger toward the end / beginning), Once i found out how to reduce the diffusion , then it will be useful :).

Does the automatic segmentation is available in 3D or not yet ? Or I need to do one by one ?

Thanks a lot, antho

constantinpape commented 7 months ago

Seems ok in 3D, but the masks diffuse too much on the out of focus (mask are getting larger toward the end / beginning), Once i found out how to reduce the diffusion , then it will be useful :).

Ok, thanks for the feedback! Will follow up on this next week. (We have seen this issue to, it should be possible to fix it by updating some parameters, will share details as soon as I can).

Does the automatic segmentation is available in 3D or not yet ? Or I need to do one by one ?

It's implemented, but there are different versions of this and not everything is fully tested. I will follow up next week.

Nal44 commented 7 months ago

Thanks, looking for the update :) Enjoy your time off :D ,

great support ! antho