BjornNyberg / Geometric-Attributes-Toolbox

The Geometric Attributes toolbox is a set of QGIS tools designed for the geometric attribute and shape characterization of modern depositional elements
GNU General Public License v3.0
76 stars 8 forks source link

QGIS problem for running SAM #21

Open bouyeijiang opened 1 year ago

bouyeijiang commented 1 year ago

QGIS version: 3.34.0-Prizren QGIS code revision: ffbdd67881 Qt version: 5.15.3 Python version: 3.9.5 GDAL version: 3.7.2 GEOS version: 3.12.0-CAPI-1.18.0 PROJ version: Rel. 9.3.0, September 1st, 2023 PDAL version: 2.5.5 (git-version: 24f78d) Algorithm started at: 2023-11-23T08:41:12 Algorithm 'Segment Anything Model (SAM)' starting… Input parameters: { 'Checkpoints' : 0, 'Mask' : 'TEMPORARY_OUTPUT', 'Polygons' : 'TEMPORARY_OUTPUT', 'Raster' : 'F:/xx/xx.tif', 'batch' : False, 'box_nms_thresh' : None, 'crop_n_layers' : None, 'crop_n_points_downscale_factor' : None, 'crop_nms_thresh' : None, 'crop_overlap_ratio' : None, 'min_mask_region_area' : None, 'points_per_batch' : None, 'points_per_side' : None, 'pred_iou_thresh' : None, 'stability_score_offset' : None, 'stability_score_thresh' : None, 'unique' : False }

Failed to load python modules for SAM predictions. Try using the configure tool or manually install the segment-geospatial package using pip install segment-geospatial. Execution completed in 0.03 seconds Results: {}

agentmorris commented 11 months ago

I had the same symptom: I had installed segment-geospatial and could successfully run "import samgeo" in the QGIS Python console, but I got the same error from the plugin. In my case, this was because I created a Python environment very recently using mamba, which as of 12/19/23 defaults to Python 3.12. I installed QGIS and segment-geospatial in that environment, using "pip install segment-geospatial". Paradoxically, this installs a very old version of segment-geospatial, I believe because very old versions of PyTorch didn't pin the Python version the same way. I.e., new versions of PyTorch are not yet compatible with Python 3.12, so pip had to install a very old version of PyTorch, which resulted in a very old version of segment-geospatial getting installed, so "from samgeo import common" didn't work.

Fixed by doing everything the same way, but in a Python 3.11 environment.

bouyeijiang commented 11 months ago

谢谢您的来信!我会及时查阅的