GroundTruth-AI / app.py
grixelle's picture
Update app.py
b612fa5 verified
import gradio as gr
from google import genai
import os
def ground_truth_engine(past_img, present_img):
api_key = os.environ.get("GOOGLE_API_KEY")
if not api_key:
return "ERROR: GOOGLE_API_KEY not found in Space Secrets."
# Initialize the new SDK client
client = genai.Client(api_key=api_key)
if past_img is None or present_img is None:
return "Please upload both images."
prompt = """
Perform a high-fidelity structural audit comparing these two images.
Focus on changes in roofing, landscaping, and exterior condition.
Conclude with a 'Maintenance Trajectory': IMPROVING, STABLE, or DECLINING.
"""
try:
response = client.models.generate_content(
model="gemini-robotics-er-1.5-preview",
contents=[prompt, past_img, present_img]
)
return response.text
except Exception as e:
return f"Analysis Failed: {str(e)}"
# Define the UI using Gradio 4 syntax
with gr.Blocks(theme=gr.themes.Soft()) as demo:
gr.Markdown("# 🏠 GroundTruth AI (Stable Build)")
gr.Markdown("Temporal Property Sentinel powered by Gemini Robotics-ER 1.5")
with gr.Row():
with gr.Column():
p_img = gr.Image(label="Past Condition", type="pil")
c_img = gr.Image(label="Current Condition", type="pil")
submit = gr.Button("Analyze Trajectory", variant="primary")
with gr.Column():
output = gr.Markdown(label="Audit Report")
submit.click(fn=ground_truth_engine, inputs=[p_img, c_img], outputs=output)
if __name__ == "__main__":
# The server_name binding is required for Docker containers on HF
demo.launch(server_name="0.0.0.0", server_port=7860)