coolzhao / Geo-SAM

A QGIS plugin tool using Segment Anything Model (SAM) to accelerate segmenting or delineating landforms in geospatial raster images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Geo-SAM python encoder

cycle4 opened this issue · comments

Hello !
Thank you for thinking about releasing a python library to encode the image without going through QGIS (even if it works very well in QGIS). However I am having troubles when I want to modify the parameters of the encoding in the settings json file. I export it from QGIS to have the "template" of the json file but I am still having issues. Can you provide an exemple of the json settings file to be sure I have the right namings ?
I am currently working with this :
{
"area_units": "m2",
"distance_units": "meters",
"ellipsoid": "EPSG:7030",
"inputs": {
"BANDS": null,
"BATCH_SIZE": 1,
"CKPT": "/home/Desktop/IMG_ENC/checkpoint/sam_vit_l_0b3195.pth",
"CRS": null,
"CUDA": true,
"CUDA_ID": 0,
"EXTENT": null,
"INPUT": "F:/exemple.tif",
"LOAD": true,
"MODEL_TYPE": 1,
"OUTPUT": "TEMPORARY_OUTPUT",
"RANGE": "None,None",
"RESOLUTION": 1.2,
"STRIDE": 922
}
}

I am not sure if this is the expected format as the library works well on a single image with the default parameters (no json settings file implied) but crashes when I try to implement the settings

By the way, I had this error trying to run it with GPU :
line 642, in
settings = {Parameter_Mapping[k]: v for k,
KeyError: 'CUDA'

It has been solved by adding to image_encoder.py line 642 this part :
settings = {Parameter_Mapping[k]: v for k, v in settings.items() if k != 'CRS' and k in Parameter_Mapping}

Thanks for your help

Hi @cycle4

The keys for the parameters are fixed. You can copy the settings from Encoder Copilot and paste it into any text editor to view all the required parameters. 'CUDA' is not in those parameters/keys, so you need to delete this parameter before running.

The default parameters are enough to run it. Our tutorials just specify the paths, without any other parameters [see Run by specify parameters directly section for more details]:

https://geo-sam.readthedocs.io/en/latest/Usage/encoder_package.html#run-by-specify-parameters-directly

I suggest you directly run the Colab tutorials, which can help you understand the results of each step in more detail.

https://colab.research.google.com/github/coolzhao/Geo-SAM/blob/dev/GeoSAM-Image-Encoder/examples/geosam-image-encoder.ipynb