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

Help for inference outside of QGIS. #35

Open notnotzero opened 4 months ago

notnotzero commented 4 months ago

Hello! I am new to machine learning and am finding it challenging to understand how to utilize the features from your Encoder in my application. It would be beneficial if someone could provide an example of how to run predictions without QGIS. Thanks a lot for future replies!

Fanchengyan commented 4 months ago

Hi @notnotzero ,

You may refer to the GeoSAM-Image-Encoder Python package documentation for more information. This package is part of the Geo-SAM project and is a standalone Python package that does not depend on QGIS. This package allows you to encode remote sensing images into features that can be recognized by Geo-SAM using a remote server, such as Colab, AWS, Azure or your own HPC.

You can click on the link below to experience GeoSAM-Image-Encoder in Colab: https://colab.research.google.com/github/coolzhao/Geo-SAM/blob/main/GeoSAM-Image-Encoder/examples/geosam-image-encoder.ipynb

The prediction process must currently be performed in QGIS. We may provide a standalone script in the future for cases where the required prompts are already available. Another option is to use samgeo, which is a pure python package developed by Qiusheng Wu

notnotzero commented 4 months ago

@Fanchengyan Thank you very much for your answer! Yes, I figured out how to run the encode script for any file outside of QGIS - the only mystery left is how to run predictions for the obtained features outside of QGIS. This will allow the use of the obtained features not only in QGIS but also in any other web applications.

Before this, I already explored the samgeo project, but its main drawback is that it does not allow for on-the-fly predictions for images. The feature generation process takes quite a lot of time in samgeo, and caching these results does not seem feasible.