First_agent_template_wea / Gradio_UI.py
21spl's picture
Update Gradio_UI.py
3454130 verified
raw
history blame
1.52 kB
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)