Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,16 +2,22 @@ import gradio as gr
|
|
| 2 |
from google import genai
|
| 3 |
import os
|
| 4 |
|
| 5 |
-
def
|
| 6 |
api_key = os.environ.get("GOOGLE_API_KEY")
|
| 7 |
if not api_key:
|
| 8 |
-
return "ERROR:
|
| 9 |
|
|
|
|
| 10 |
client = genai.Client(api_key=api_key)
|
|
|
|
| 11 |
if past_img is None or present_img is None:
|
| 12 |
-
return "
|
| 13 |
|
| 14 |
-
prompt = "
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 (
|
|
|
|
|
|
|
| 27 |
with gr.Row():
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
if __name__ == "__main__":
|
| 35 |
-
#
|
| 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)
|