grixelle commited on
Commit
985ee90
·
verified ·
1 Parent(s): 2976af0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -31
app.py CHANGED
@@ -1,62 +1,46 @@
1
  import gradio as gr
2
  from google import genai
3
  import os
4
- from PIL import Image
5
 
6
  def ground_truth_audit(past_img, present_img):
7
- """
8
- Forensic structural audit using Gemini Robotics-ER 1.5.
9
- Uses the new google-genai SDK for stability.
10
- """
11
  api_key = os.environ.get("GOOGLE_API_KEY")
12
  if not api_key:
13
- return "## Configuration Error\nAPI Key missing. Please set GOOGLE_API_KEY in Space Secrets."
14
 
15
- # Initialize the new SDK client
16
  client = genai.Client(api_key=api_key)
17
 
18
- if past_img is None or present_img is None:
19
- return "Error: Please upload both 'Past' and 'Present' images."
20
-
21
- # Robotics-specific prompt for spatial reasoning
22
  prompt = """
23
- Perform a high-fidelity structural audit comparing these two images.
24
- Focus on:
25
- 1. Roofing & Gutters (wear, shingle quality, replacement evidence)
26
- 2. Landscaping (maturity, maintenance, or invasive overgrowth)
27
- 3. Exterior Envelope (paint, siding, window fixtures)
28
 
29
- Output a 'Maintenance Trajectory' as: IMPROVING, DECLINING, or STABLE.
30
- Include specific physical evidence for your conclusion.
31
  """
32
 
33
  try:
34
- # Generate content using the Robotics-ER preview model
35
  response = client.models.generate_content(
36
  model="gemini-robotics-er-1.5-preview",
37
  contents=[prompt, past_img, present_img]
38
  )
39
-
40
  return response.text
41
-
42
  except Exception as e:
43
  return f"## Analysis Failed\n{str(e)}"
44
 
45
- # Define the Interface for maximum stability
46
- # gr.Interface handles the side-by-side layout and 'Analyze' button automatically
47
  demo = gr.Interface(
48
  fn=ground_truth_audit,
49
  inputs=[
50
- gr.Image(label="Past Condition (Historical)", type="pil"),
51
- gr.Image(label="Present Condition (Current)", type="pil")
52
  ],
53
  outputs=gr.Markdown(),
54
- title="🏠 GroundTruth: Temporal Property Sentinel",
55
- description="Powered by Gemini Robotics-ER 1.5. A forensic engine for tracking property 'Pride of Ownership' over time.",
56
- theme="soft",
57
- allow_flagging="never"
58
  )
59
 
60
  if __name__ == "__main__":
61
- # Enabling queue ensures the server can handle the 10-20s latency
62
- demo.queue().launch()
 
1
  import gradio as gr
2
  from google import genai
3
  import os
 
4
 
5
  def ground_truth_audit(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
  client = genai.Client(api_key=api_key)
11
 
12
+ # Robotics-ER 1.5 requires precise prompts for spatial reasoning
 
 
 
13
  prompt = """
14
+ Perform a structural audit comparing these two images.
15
+ 1. Roofing & Gutters: Look for shingle wear or replacement.
16
+ 2. Landscaping: Identify maturity or neglect.
17
+ 3. Exterior: Check paint and siding condition.
 
18
 
19
+ Conclude with a 'Maintenance Trajectory': IMPROVING, STABLE, or DECLINING.
 
20
  """
21
 
22
  try:
23
+ # Call the Robotics-ER 1.5 preview model
24
  response = client.models.generate_content(
25
  model="gemini-robotics-er-1.5-preview",
26
  contents=[prompt, past_img, present_img]
27
  )
 
28
  return response.text
 
29
  except Exception as e:
30
  return f"## Analysis Failed\n{str(e)}"
31
 
32
+ # The Interface class is the 'Architectural Safe Mode' for Gradio
 
33
  demo = gr.Interface(
34
  fn=ground_truth_audit,
35
  inputs=[
36
+ gr.Image(label="Past Condition", type="pil"),
37
+ gr.Image(label="Present Condition", type="pil")
38
  ],
39
  outputs=gr.Markdown(),
40
+ title="GroundTruth AI",
41
+ description="Spatial Property Analysis via Gemini Robotics-ER 1.5",
42
+ theme="default"
 
43
  )
44
 
45
  if __name__ == "__main__":
46
+ demo.launch()