pytorch-labs / segment-anything-fast

A batched offline inference oriented version of segment-anything
Apache License 2.0
1.21k stars 72 forks source link

Issue with opencv-python and SamAutomaticMaskGenerator #124

Closed beschmitt closed 5 months ago

beschmitt commented 5 months ago

I have installed my environment exactly like in the README.md in the experiments folder but I have two issues when trying to run the code in the amg_example.py

  1. Can't import cv2 When trying to import cv2 I get the following error: "ImportError: libGL.so.1: cannot open shared object file: No such file or directory"

I have tried uninstalling and reinstalling opencv-python which didn't work. I have also tried uninstalling opencv-python and installing opencv-python-headless but that didn't work either

  1. SamAutomaticMaskGenerator throwing a compiler-error I read in an image with torchvision.io.read_image and tried generating masks for it but I got the following error:

BackendCompilerFailed Traceback (most recent call last) Cell In[18], [line 1](vscode-notebook-cell:?execution_count=18&line=1) ----> [1](vscode-notebook-cell:?execution_count=18&line=1) masks = mask_generator.generate(image) You can suppress this exception and fall back to eager by setting: import torch._dynamo torch._dynamo.config.suppress_errors = True

After trying the suggested fix of setting the suppress_errors to True I get the following error: NotImplementedError PythonTLSSnapshot: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:161 [backend fallback] FuncTorchDynamicLayerFrontMode: registered at ../aten/src/ATen/functorch/DynamicLayer.cpp:493 [backend fallback] PreDispatch: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:165 [backend fallback] PythonDispatcher: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:157 [backend fallback]

These are not the full error messages since posting the full error log would exceed the character-limit.

I have no idea what this means and I can't find any fixes anywhere.