segment-geospatial icon indicating copy to clipboard operation
segment-geospatial copied to clipboard

Expose leafmap backend options to user

Open openSourcerer9000 opened this issue 1 year ago • 7 comments

Based on this phenomenon (https://github.com/opengeos/leafmap/issues/707#issue-2198216506), I would like to be able to swap out the default backend for folium in hopes of getting this library to work with Kaggle Notebooks. Currently the API doesn't allow for this. image

With how different backends are loaded, this may be a sensible way of changing the backend:

import leafmap.foliumap as leafmap
sam = SamGeo(
    model_type="vit_h",
    automatic=False,
    sam_kwargs=None,
    leafmap_backend=leafmap
)

openSourcerer9000 avatar Mar 20 '24 18:03 openSourcerer9000

Unfortunately, the interactive GUI requires ipyleaflet and ipyleaflet. Folium is very limited. It can't handle user input.

If you just need to display the image and segmentation results, you can still use the folium backend.

I would suggest you use Colab before the ipyleaflet issue is resolved in Kaggle.

giswqs avatar Mar 20 '24 20:03 giswqs

I tried google Colab first but I wasn't able to get a working environment setup. After installing samgeo and its dependencies in a GPU session, the notebook was no longer able to access the GPU (torch.cuda.is_available() Returns false). Seeing a similar issue in the Colab repo, they say they only maintain the base environment and anything else it's up to you to configure the packages correctly. While still trying to debug this, Colab locked me out of GPU sessions, which is when I tried switching to Kaggle.

This is where I left off; If you know how to get a working environment with samgeo and cuda in Colab that would be a big help: https://colab.research.google.com/drive/1oO6MCY15pCVJdrY0db9S2vbFKyKGY-6O?usp=sharing

openSourcerer9000 avatar Mar 21 '24 11:03 openSourcerer9000

did you try pip install segment-geospatial on Colab?

giswqs avatar Mar 21 '24 13:03 giswqs

Ah thanks that's much simpler and it does work. When I click segment in the interactive window, it does run the model, but it won't show the output segmentation layer on the map. Have you seen it work in Colab?

openSourcerer9000 avatar Mar 21 '24 16:03 openSourcerer9000

It used to work. I have not used it recently. Need sometime to look into it

giswqs avatar Mar 21 '24 16:03 giswqs

The only environment that I've gotten the segmentation to work reliably is jupyterlab. However, the save button doesn't seem to work in jupyterlab. Is there a way to access the layer from code? The following commands hit javascript errors: image

openSourcerer9000 avatar Mar 26 '24 12:03 openSourcerer9000

Have you tried it on Google Colab? Did it work? I have not encourtered this issue before. Can you provide a notebook that can reproduce the issue?

giswqs avatar Mar 30 '24 15:03 giswqs