royerlab / napari-segment-anything

Segment Anything Model (SAM) native Qt UI
Apache License 2.0
190 stars 17 forks source link

MPS framework error #10

Open TomPJWyatt opened 1 year ago

TomPJWyatt commented 1 year ago

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..

JoOkuma commented 1 year ago

Hey @TomPJWyatt , thanks for reporting this error.

I'm having trouble reproducing it, can you share the image you're having trouble with? And can you report the entire error you're getting?

TomPJWyatt commented 1 year ago

Thanks Jordão, I've emailed you the image and full error

rouarouatbi commented 1 year ago

I'm also getting the same error for my images

JoOkuma commented 1 year ago

Hi @rouarouatbi, the official segment-anything still needs to accept the changes to fix this issue.

You can install the necessary changes, facebookresearch/segment-anything#122, with

pip install git+https://github.com/DrSleep/segment-anything@mps-support

And you have to set the environment variable PYTORCH_ENABLE_MPS_FALLBACK=1.