grixelle commited on
Commit
4dbd17e
·
verified ·
1 Parent(s): 4bc6f49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
app.py CHANGED
@@ -2,16 +2,22 @@ import gradio as gr
2
  from google import genai
3
  import os
4
 
5
- def audit_engine(past_img, present_img):
6
  api_key = os.environ.get("GOOGLE_API_KEY")
7
  if not api_key:
8
- return "ERROR: Set GOOGLE_API_KEY in Space Secrets."
9
 
 
10
  client = genai.Client(api_key=api_key)
 
11
  if past_img is None or present_img is None:
12
- return "Upload both images."
13
 
14
- prompt = "Perform a structural audit. Compare roofing, landscaping, and exterior condition. Output a 'Maintenance Trajectory': IMPROVING, STABLE, or DECLINING."
 
 
 
 
15
 
16
  try:
17
  response = client.models.generate_content(
@@ -22,15 +28,22 @@ def audit_engine(past_img, present_img):
22
  except Exception as e:
23
  return f"Analysis Failed: {str(e)}"
24
 
 
25
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
26
- gr.Markdown("# 🏠 GroundTruth AI (Docker Stable)")
 
 
27
  with gr.Row():
28
- p_img = gr.Image(label="Past", type="pil")
29
- c_img = gr.Image(label="Present", type="pil")
30
- output = gr.Markdown(label="Audit Report")
31
- submit = gr.Button("Analyze", variant="primary")
32
- submit.click(fn=audit_engine, inputs=[p_img, c_img], outputs=output)
 
 
 
 
33
 
34
  if __name__ == "__main__":
35
- # In Docker, you MUST bind to 0.0.0.0 and port 7860
36
  demo.queue().launch(server_name="0.0.0.0", server_port=7860)
 
2
  from google import genai
3
  import os
4
 
5
+ def ground_truth_engine(past_img, present_img):
6
  api_key = os.environ.get("GOOGLE_API_KEY")
7
  if not api_key:
8
+ return "ERROR: GOOGLE_API_KEY not found in Space Secrets."
9
 
10
+ # Initialize the new SDK client
11
  client = genai.Client(api_key=api_key)
12
+
13
  if past_img is None or present_img is None:
14
+ return "Please upload both images."
15
 
16
+ prompt = """
17
+ Perform a high-fidelity structural audit comparing these two images.
18
+ Focus on changes in roofing, landscaping, and exterior condition.
19
+ Conclude with a 'Maintenance Trajectory': IMPROVING, STABLE, or DECLINING.
20
+ """
21
 
22
  try:
23
  response = client.models.generate_content(
 
28
  except Exception as e:
29
  return f"Analysis Failed: {str(e)}"
30
 
31
+ # Define the UI using Gradio 4 syntax
32
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
33
+ gr.Markdown("# 🏠 GroundTruth AI (Stable Build)")
34
+ gr.Markdown("Temporal Property Sentinel powered by Gemini Robotics-ER 1.5")
35
+
36
  with gr.Row():
37
+ with gr.Column():
38
+ p_img = gr.Image(label="Past Condition", type="pil")
39
+ c_img = gr.Image(label="Current Condition", type="pil")
40
+ submit = gr.Button("Analyze Trajectory", variant="primary")
41
+
42
+ with gr.Column():
43
+ output = gr.Markdown(label="Audit Report")
44
+
45
+ submit.click(fn=ground_truth_engine, inputs=[p_img, c_img], outputs=output)
46
 
47
  if __name__ == "__main__":
48
+ # Standard Docker bindings for Hugging Face Spaces
49
  demo.queue().launch(server_name="0.0.0.0", server_port=7860)