royerlab / napari-segment-anything Goto Github PK
View Code? Open in Web Editor NEWSegment Anything Model (SAM) native Qt UI
License: Apache License 2.0
Segment Anything Model (SAM) native Qt UI
License: Apache License 2.0
Platform:
OSX Ventura 13.3 (22E252)
Conda env:
name: test_env
channels:
- conda-forge
dependencies:
- python=3.9
- nomkl
- ca-certificates
- openssl
- napari
- pip:
- filelock==3.12.0
- mpmath==1.3.0
- napari-segment-anything==0.1.4
- segment-anything==1.0
- sympy==1.12
- torch==2.0.1
- torchvision==0.15.2
When installing napari
alongside the latest pip install git+https://github.com/jookuma/napari-segment-anything.git
I get the following error when trying to open the widget.
OMP: Error #15: Initializing libiomp5.dylib, but found libomp.dylib already initialized.
OMP: Hint This means that multiple copies of the OpenMP runtime have been linked into the program. That is dangerous, since it can degrade performance or cause incorrect results. The best thing to do is to ensure that only a single OpenMP runtime is linked into the process, e.g. by avoiding static linking of the OpenMP runtime in any library. As an unsafe, unsupported, undocumented workaround you can set the environment variable KMP_DUPLICATE_LIB_OK=TRUE to allow the program to continue to execute, but that may cause crashes or silently produce incorrect results. For more information, please see http://www.intel.com/software/products/support/.
Tried to find similar issues and recomment conda install nomkl
but for me does not seem to work either.
Hi there,
I'm just trying out your plugin and it very nicely works when no segmentations are available. I was wondering if there is any support (or further interest to implement this) for having the "SAM box" and "SAM points" layers operate on existing labels layers whenever a segmentation mask is already available and needs to be slightly corrected?
Thanks,
Christina
I ran into this for reasons related to the MPS device issues (I'm on a MBP M1) #10.
It would be nice to be able to specify the compute device, particularly to make it easier to test on CPU.
Hi there,
thanks for this great plugin. I have noticed that when I change the model, all previously created labels are deleted from the SAM labels layer. It would be great to be able to continue working on a previously created labels layer.
Hi thanks for the interesting project, I am running this from my local computer connected to a remote server. When I try to run napari, it gives the error: Could not load the Qt platform plugin "xcb" in "" even though it was found. and when in debug says cannot connect to display. I tried with both pyqt5 and pyside2. I also tried solutions https://forum.image.sc/t/cant-open-napari-with-jupyter-and-vs-code-module-napari-has-no-attribute-viewer-runtimeerror-no-qt-app-has-been-created/71353/3, https://github.com/NVlabs/instant-ngp/discussions/300 and more but could not resolve it yet. Could you please help about this. Thank you.
Traceback (most recent call last):
File "C:\conda\envs\yolov5\lib\runpy.py", line 194, in _run_module_as_main
return run_code(code, main_globals, None,
File "C:\conda\envs\yolov5\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\conda\envs\yolov5\Scripts\napari.exe_main.py", line 7, in
File "C:\conda\envs\yolov5\lib\site-packages\napari_main.py", line 561, in main
run()
File "C:\conda\envs\yolov5\lib\site-packages\napari_main.py", line 370, in _run
first_dock_widget = viewer.window.add_plugin_dock_widget(
File "C:\conda\envs\yolov5\lib\site-packages\napari_qt\qt_main_window.py", line 717, in add_plugin_dock_widget
wdg = _instantiate_dock_widget(
File "C:\conda\envs\yolov5\lib\site-packages\napari_qt\qt_main_window.py", line 1365, in _instantiate_dock_widget
return wdg_cls(**kwargs)
File "C:\conda\envs\yolov5\lib\site-packages\napari_segment_anything_widget.py", line 91, in init
self._model_type_widget.changed.emit(model_type)
File "src\psygnal_signal.py", line 927, in emit
File "src\psygnal_signal.py", line 974, in _run_emit_loop
psygnal._exceptions.EmitLoopError: calling <psygnal._weak_callback._WeakMethod object at 0x000001FA4574BB40> with args=('default',) caused ValueError: Only 2D images supported. Got 3-dim image..
Exited as it showed. Why is 3-dim image not supported?
Hey Jordão, thanks for this plugin, I'm excited to try it!
At the moment I'm getting the below error when I press Auto. Segm.
EmitLoopError: calling <psygnal._weak_callback._WeakMethod object at 0x16e052160> with args=(False,) caused TypeError: Cannot convert a MPS Tensor to float64 dtype as the MPS framework doesn't support float64. Please use float32 instead..
Sonoma 14.4
M3 Max
Tried running this in three different conda envs, with both the dev version and standard version. One of the envs is a completely clean env with only Napari and napari-segment-anything installed.
When I click on the plugin in the plugin dropdown, Napari shuts down with the error message in the clean env being:
/opt/homebrew/Caskroom/miniforge/base/envs/napari-sam/lib/python3.10/site-packages/napari/components/viewer_model.py:10: FutureWarning: Labels.color is deprecated since 0.4.19 and will be removed in 0.5.0, please set Labels.colormap directly with an instance of napari.utils.colormaps.DirectLabelColormap instead.!
But that warning does seem to have anything to do with the closing of Napari as far as I can tell.
Thanks to the author for open source, but I still don't quite understand how to use this code to get the interface SAM, can you give instructions in the readme, thank you very much
Hi,
I managed to run the SAM in my napari but whenever I want to open an image I get the following error message: "invalid value encountered in cast"
I there something I can change to get rid of this error?
Thanks!
Hi there,
I wanted to try out MedSAM in your Napari plugin, and the cheapest way was to download their model checkpoint, renaming it to sam_vit_b_01ec64.pth
and replacing that file in the .cache/napari-segment-anything
folder. Of course, one has to first select the vit_b model in the plugin widget such that it appears in the folder.
So this is more of a feature request. Allow users to try out other SAM checkpoints by being able to choose a model checkpoint location via the widget.
add mac gpu support if available
hi, thanks for your amazing work on this convenient plugin.
I want to use it to label some structures of knee in 3D MR images. There is no problem in handling single or very few images. However, when I import the normal series images and follow the routine, the first click will be ok, but the following click will lead to the sudden enlargement of image numbers and the labeling won't work anymore. It will be great if you figure it out. Thanks!
Nice plugin, seems to work quite well. After getting the SAM Label layer how is this data exported to json or csv file? Is there another plugin used for that?
Reference: https://github.com/ChaoningZhang/MobileSAM
Our project performs on par with the original SAM and keeps exactly the same pipeline as the original SAM except for a change on the image encode, therefore, it is easy to Integrate into any project.
MobileSAM is around 60 times smaller and around 50 times faster than original SAM, and it is around 7 times smaller and around 5 times faster than the concurrent FastSAM. The comparison of the whole pipeline is summarzed as follows:
Best Wishes,
Qiao
Hi @JoOkuma ,
I'm getting an error when I open, close and re-open the plugin. The error is this:
self = <Container ()>
97 self._viewer.bind_key("X", self._cancel_annot)
File ~\Anaconda3\envs\pytorch\lib\site-packages\napari\utils\key_bindings.py:286, in bind_key(keymap={'C': <bound method SAMWidget._on_confirm_mask of <Container ()>>, 'X': <bound method SAMWidget._cancel_annot of <Container ()>>}, key='C', func=<bound method SAMWidget._on_confirm_mask of <Container ()>>, overwrite=False)
283 key = normalize_key_combo(key)
285 if func is not None and key in keymap and not overwrite:
--> 286 raise ValueError(
trans = <napari.utils.translations.TranslationBundle object at 0x000002265A114730>
key = 'C'
287 trans._(
288 'key combination {key} already used! specify \'overwrite=True\' to bypass this check',
289 deferred=True,
290 key=key,
291 )
292 )
294 unbound = keymap.pop(key, None)
296 if func is not None:
ValueError: key combination C already used! specify 'overwrite=True' to bypass this check
Open the plugin in napari, close it again, and re-open it.
The error message points to this line in the code. Adding an overwrite=True
to this line fixes it.
PR coming :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.