File size: 1,742 Bytes
11faaa7
498291b
11faaa7
 
4dbd17e
b949118
11faaa7
4dbd17e
b949118
4dbd17e
498291b
4dbd17e
2c9a7b3
4dbd17e
2c9a7b3
4dbd17e
 
 
 
 
11faaa7
b949118
498291b
 
 
 
b949118
 
7b78a5c
b949118
4dbd17e
b9974f1
4dbd17e
 
 
2c9a7b3
4dbd17e
 
 
 
 
 
 
 
 
11faaa7
b9974f1
b612fa5
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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)