File size: 1,519 Bytes
3454130
deafbd7
 
3454130
deafbd7
3454130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deafbd7
3454130
 
deafbd7
3454130
deafbd7
3454130
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr

class GradioUI:
    def __init__(self, agent):
        self.agent = agent
        self.interface = self._create_interface()

    def _create_interface(self):
        with gr.Blocks(title="Landsat Image Fetcher") as demo:
            gr.Markdown("# Landsat Image Fetcher")
            gr.Markdown("Enter coordinates and a time range to fetch Landsat images from USGS.")
            with gr.Row():
                with gr.Column():
                    lat_min = gr.Number(label="Min Latitude", value=37.75)
                    lon_min = gr.Number(label="Min Longitude", value=-122.35)
                    lat_max = gr.Number(label="Max Latitude", value=37.85)
                    lon_max = gr.Number(label="Max Longitude", value=-122.25)
                    start_date = gr.Textbox(label="Start Date (YYYY-MM-DD)", value="2023-01-01")
                    end_date = gr.Textbox(label="End Date (YYYY-MM-DD)", value="2023-12-31")
                    submit_btn = gr.Button("Fetch Images")
                with gr.Column():
                    output = gr.HTML(label="Download Links")
            submit_btn.click(
                fn=lambda lm, ln, lx, lo, sd, ed: self.agent.run(
                    f"fetch_landsat_image({lm}, {ln}, {lx}, {lo}, '{sd}', '{ed}')"
                ),
                inputs=[lat_min, lon_min, lat_max, lon_max, start_date, end_date],
                outputs=output
            )
        return demo

    def launch(self, **kwargs):
        self.interface.launch(**kwargs)