coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.
MIT License
199 stars 26 forks source link

Image encoder on the CPU. #21

Closed OMilosh closed 9 months ago

OMilosh commented 9 months ago

Hello! Thanks for your work. I can’t run the image encoder on the CPU due to the error in the screenshot below. Screenshot_1 Where could the error be? All dependencies are installed according to the tutorial.

OMilosh commented 9 months ago

Traceback (most recent call last): File "C:\Users/User/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\tools\sam_processing_algorithm.py", line 491, in processAlgorithm self.sam_model = self.initialize_sam( File "C:\Users/User/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Geo-SAM\tools\sam_processing_algorithm.py", line 627, in initialize_sam sam_model = sam_model_registry[model_type]( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 28, in build_sam_vit_l return _build_sam( File "C:\Users\User\AppData\Roaming\Python\Python39\site-packages\segment_anything\build_sam.py", line 105, in _build_sam state_dict = torch.load(f) File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 809, in load return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args) File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1172, in _load result = unpickler.load() File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1142, in persistent_load typed_storage = load_tensor(dtype, nbytes, key, _maybe_decode_ascii(location)) File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 1116, in load_tensor wrap_storage=restore_location(storage, location), File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 217, in default_restore_location result = fn(storage, location) File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 182, in _cuda_deserialize device = validate_cuda_device(location) File "C:\PROGRA~1\QGIS33~1.2\apps\Python39\lib\site-packages\torch\serialization.py", line 166, in validate_cuda_device raise RuntimeError('Attempting to deserialize object on a CUDA ' RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

coolzhao commented 9 months ago

This is strange. Have you tried to uncheck the 'using CUDA' option?

OMilosh commented 9 months ago

Yes. image

OMilosh commented 9 months ago

Sorry, it turned out to be my mistake. I used the wrong checkpoint. Thanks!

poitevie commented 8 months ago

Hello ! I have the same problem when unchecking the box and it doesn't matter which checkpoint I use... Do you know why?

coolzhao commented 8 months ago

Hi @poitevie, did you download the SAM checkpoint or just use the checkpoint included in the plugin? They are for different purposes. Please follow the link below to download the SAM checkpoint for encoding. https://geo-sam.readthedocs.io/en/latest/Usage/encoding.html