Interactive Moondream GUI with Leafmap¶
This notebook demonstrates how to use the interactive Moondream GUI for geospatial image analysis with leafmap.
Features¶
The Moondream GUI provides an interactive interface for:
- Caption: Generate image descriptions (short, normal, or long)
- Query: Ask questions about the image (visual Q&A)
- Detect: Detect objects and display bounding boxes on the map
- Point: Locate objects and display point markers on the map
Installation¶
Uncomment and run the following cell to install the required packages.
In [ ]:
Copied!
# %pip install -U geoai-py
# %pip install -U geoai-py
Import Libraries¶
In [ ]:
Copied!
import geoai
from geoai import MoondreamGeo
import geoai
from geoai import MoondreamGeo
Download Sample Data¶
We'll use a sample parking lot image for this demonstration.
In [ ]:
Copied!
url = "https://huggingface.co/datasets/giswqs/geospatial/resolve/main/parking_lot.tif"
image_path = geoai.download_file(url)
image_path
url = "https://huggingface.co/datasets/giswqs/geospatial/resolve/main/parking_lot.tif"
image_path = geoai.download_file(url)
image_path
Initialize Moondream¶
Create a MoondreamGeo instance and load the image.
In [ ]:
Copied!
moondream = MoondreamGeo()
moondream.load_image(image_path)
moondream = MoondreamGeo()
moondream.load_image(image_path)
Launch the Interactive GUI¶
The GUI provides the following controls:
- Mode: Select between Caption, Query, Detect, or Point
- Prompt: Enter text for Query, Detect, or Point modes
- Length: Select caption length (short, normal, long) for Caption mode
- Opacity: Adjust overlay opacity
- Color: Choose color for detection boxes and point markers
- Run: Execute the selected operation
- Save: Save results to file
- Reset: Clear all results and reset the interface
Tips:¶
- For Detect mode, enter object types like "building", "trees"
- For Point mode, describe objects to locate like "green tree", "white building"
- For Query mode, ask questions like "How many buildings are in the image?"
- Detection results are displayed as bounding boxes on the map
- Point results are displayed as circle markers on the map
In [ ]:
Copied!
m = moondream.show_gui()
m
m = moondream.show_gui()
m
In [ ]:
Copied!
gdf = m.last_result_as_gdf
gdf
gdf = m.last_result_as_gdf
gdf