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

Square segmentation #11

Open 4del-Yousefi opened 11 months ago

4del-Yousefi commented 11 months ago

Hello, thank you for frequently updating the code and fixing issues. I am working on drone tif images, and I have encountered an issue where a square segmentation occurs when I select multiple objects or a large area.

Here is an example: image

Fanchengyan commented 11 months ago

Hi @4del-Yousefi , this issue lies in the fact that the input images from SAM can only be of size 1024×1024. However, in your case, the image is too large, and the entire image will be devided into many overlapping batches during the encode image process. Unfortunately, 1024×1024 pixels do not cover the objects on the ground in your usage scenario. To address this problem, you can reduce the output resolution in the image encoder tool. We have just released a new version of this plugin that includes an Encoder Copilot.This widget allows you to view the adjusted batch size in real-time and copy settings to Image Encoder tool. Feel free to give it a try.

coolzhao commented 11 months ago

Hi @4del-Yousefi, thanks for your comments.

Based on your screenshot, the boundary effect is due to our tool's patch-sampling strategy to handle large images, which @Fanchengyan mentions.

But based on the description in your comment

... a square segmentation occurs when I select multiple objects ...

, you may not use the tool correctly since you should deal with only one object once before pressing the save button (as mentioned in the readme). This is how SAM is designed to work; the serial prompts you added are all for segmenting one object.

4del-Yousefi commented 11 months ago

Hi @4del-Yousefi, thanks for your comments.

Based on your screenshot, the boundary effect is due to our tool's patch-sampling strategy to handle large images, which @Fanchengyan mentions.

But based on the description in your comment

... a square segmentation occurs when I select multiple objects ...

, you may not use the tool correctly since you should deal with only one object once before pressing the save button (as mentioned in the readme). This is how SAM is designed to work; the serial prompts you added are all for segmenting one object.

I select only select 1 object, i faced this issue when trying to segment a building rooftop. I think the issue is with the resolution. Can you please guide me on how to change the output resolution?

Fanchengyan commented 11 months ago

Hi @4del-Yousefi , you can download the latest version of Geo-SAM-dev. We have added a Encoder Copilot in this version. You can adjust the Resolution Scale to see if the red batch size in the upper right corner can cover the object. Once you have made the adjustments, you can copy the settings and paste the parameters into the Image Encoder. ([Encoder Copilot] Copy settings -->[Encoding tool] Advanced->Paste Settings)

20230807022142

image

coolzhao commented 11 months ago

Hi @4del-Yousefi, there are several ways to change resolutions: The first way is to resample the image in advance by yourself. The second way is to set the target resolution (in meters) in the Advanced Parameters of the Encoding Tool. The third way is using the Encoder Copilot tool to set the resolution scale, which currently only supports images with a CRS in meter units.