Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,30 +13,35 @@ def ground_truth_engine(past_img, present_img, audit_level, progress=gr.Progress
|
|
| 13 |
if past_img is None or present_img is None:
|
| 14 |
return "Please upload both images."
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
|
|
|
| 22 |
|
| 23 |
prompt = f"""
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
"""
|
| 29 |
|
| 30 |
try:
|
| 31 |
-
progress(0.5, desc="Robotics-ER is
|
| 32 |
|
| 33 |
-
# We pass the audit level intent into the generation config
|
| 34 |
response = client.models.generate_content(
|
| 35 |
model="gemini-robotics-er-1.5-preview",
|
| 36 |
-
contents=[prompt, past_img, present_img]
|
| 37 |
-
config={
|
| 38 |
-
"thinking_budget": selected_budget
|
| 39 |
-
}
|
| 40 |
)
|
| 41 |
|
| 42 |
progress(1.0, desc="Audit Complete!")
|
|
@@ -51,18 +56,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 51 |
with gr.Column():
|
| 52 |
p_img = gr.Image(label="Past Condition", type="pil")
|
| 53 |
c_img = gr.Image(label="Current Condition", type="pil")
|
| 54 |
-
|
| 55 |
-
# New UI Element: Audit Level Slider
|
| 56 |
audit_slider = gr.Radio(
|
| 57 |
choices=["Quick Scan", "Standard Audit", "Deep Forensic"],
|
| 58 |
value="Standard Audit",
|
| 59 |
-
label="Audit Depth
|
| 60 |
)
|
| 61 |
-
|
| 62 |
submit = gr.Button("Analyze Structural Trajectory", variant="primary")
|
| 63 |
|
| 64 |
with gr.Column():
|
| 65 |
-
output = gr.Markdown(label="Audit Report")
|
| 66 |
|
| 67 |
submit.click(
|
| 68 |
fn=ground_truth_engine,
|
|
|
|
| 13 |
if past_img is None or present_img is None:
|
| 14 |
return "Please upload both images."
|
| 15 |
|
| 16 |
+
# Directives updated to request normalized coordinates (0-1000)
|
| 17 |
+
audit_directives = {
|
| 18 |
+
"Quick Scan": "Perform a rapid structural overview.",
|
| 19 |
+
"Standard Audit": "Compare roofing, landscaping, and exterior siding.",
|
| 20 |
+
"Deep Forensic": """Perform an exhaustive spatial audit.
|
| 21 |
+
For the 3 most significant structural changes, identify their center points
|
| 22 |
+
using normalized [y, x] coordinates (0-1000).
|
| 23 |
+
Identify subtle shingle wear, foundation cracks, and biological encroachment."""
|
| 24 |
+
}
|
| 25 |
|
| 26 |
+
selected_directive = audit_directives.get(audit_level, audit_directives["Standard Audit"])
|
| 27 |
+
progress(0.2, desc=f"Mode: {audit_level}")
|
| 28 |
|
| 29 |
prompt = f"""
|
| 30 |
+
SYSTEM INSTRUCTION: You are a forensic structural appraiser using spatial grounding.
|
| 31 |
+
DIRECTIVE: {selected_directive}
|
| 32 |
+
|
| 33 |
+
TASK: Compare these images.
|
| 34 |
+
1. List the structural findings.
|
| 35 |
+
2. Provide the [y, x] coordinates for points of interest if in Deep Forensic mode.
|
| 36 |
+
3. Conclude with 'Maintenance Trajectory': IMPROVING, STABLE, or DECLINING.
|
| 37 |
"""
|
| 38 |
|
| 39 |
try:
|
| 40 |
+
progress(0.5, desc="Robotics-ER is calculating spatial points...")
|
| 41 |
|
|
|
|
| 42 |
response = client.models.generate_content(
|
| 43 |
model="gemini-robotics-er-1.5-preview",
|
| 44 |
+
contents=[prompt, past_img, present_img]
|
|
|
|
|
|
|
|
|
|
| 45 |
)
|
| 46 |
|
| 47 |
progress(1.0, desc="Audit Complete!")
|
|
|
|
| 56 |
with gr.Column():
|
| 57 |
p_img = gr.Image(label="Past Condition", type="pil")
|
| 58 |
c_img = gr.Image(label="Current Condition", type="pil")
|
|
|
|
|
|
|
| 59 |
audit_slider = gr.Radio(
|
| 60 |
choices=["Quick Scan", "Standard Audit", "Deep Forensic"],
|
| 61 |
value="Standard Audit",
|
| 62 |
+
label="Audit Depth"
|
| 63 |
)
|
|
|
|
| 64 |
submit = gr.Button("Analyze Structural Trajectory", variant="primary")
|
| 65 |
|
| 66 |
with gr.Column():
|
| 67 |
+
output = gr.Markdown(label="Forensic Audit Report")
|
| 68 |
|
| 69 |
submit.click(
|
| 70 |
fn=ground_truth_engine,
|