Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoSAM plugin fails to load ValueError #47

Open
klara4390 opened this issue Sep 9, 2024 · 5 comments
Open

GeoSAM plugin fails to load ValueError #47

klara4390 opened this issue Sep 9, 2024 · 5 comments

Comments

@klara4390
Copy link

Hi - I am quite new to using python - so I probably don't have all the necessary details included in the first try - let me know what is missing.

Trying to load the plugin from the QGIS plugin manager gives following error:
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

I am using 3.34.10-Prizren and Python 3.9.5.

Hope someone can help :)

@Fanchengyan
Copy link
Collaborator

Hi @klara4390

Did you adhere to the installation steps on https://geo-sam.readthedocs.io/en/latest/installation.html? Besides, please share the full error message to help us diagnose the problem.

@klara4390
Copy link
Author

klara4390 commented Sep 11, 2024

I did - Today QGIS is for some reason able to load the plugin, but the following error message is given when testing segmentation on the beiluhe image.

From "python error":
raceback (most recent call last):
File "/Users/klarasorensen/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/geo_sam_tool.py", line 403, in execute_segmentation
if not self.sam_model.sam_predict(
File "/Users/klarasorensen/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/SAMTool.py", line 94, in sam_predict
self.sample = self.test_features[query]
File "/Users/klarasorensen/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/torchgeo_sam.py", line 376, in getitem
tensor = torch.tensor(dest) # .float()
RuntimeError: Could not infer dtype of numpy.float32

@klara4390
Copy link
Author

And similar error when trying to encode an image:

Traceback (most recent call last):
File "/Users/klarasorensen/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/sam_processing_algorithm.py", line 527, in processAlgorithm
for current, batch in enumerate(ds_dataloader):
File "/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 631, in next
data = self._next_data()
File "/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9/site-packages/torch/utils/data/dataloader.py", line 675, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/Applications/QGIS-LTR.app/Contents/MacOS/lib/python3.9/site-packages/torch/utils/data/_utils/fetch.py", line 51, in
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/Users/klarasorensen/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/Geo-SAM/tools/torchgeo_sam.py", line 485, in getitem
tensor = torch.tensor(dest) # .float()
RuntimeError: Could not infer dtype of numpy.int32

Execution failed after 9.70 seconds

@Fanchengyan
Copy link
Collaborator

This issue appears to stem from an incompatibility between certain versions of PyTorch and NumPy.

https://stackoverflow.com/questions/74722112/runtimeerror-could-not-infer-dtype-of-numpy-float32-when-trying-to-learn-ml-a

Unity-Technologies/ml-agents#6010

Try to update or downgrade your NumPy version to see if it works.

@Fanchengyan
Copy link
Collaborator

Fanchengyan commented Dec 16, 2024

Hi @klara4390

I encountered this issue on macOS as well. I was able to resolve it by updating the versions of numpy and pandas:

cd /Applications/QGIS.app/Contents/MacOS/bin

./pip3 install 'numpy<2' pandas -U

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants