Update app.py
Browse files
app.py
CHANGED
|
@@ -200,19 +200,32 @@ def detect_defects(image):
|
|
| 200 |
logging.error(f"Detection failed: {str(e)}")
|
| 201 |
return None, f"Detection failed: {str(e)}"
|
| 202 |
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
)
|
| 215 |
-
)
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
-
demo.launch(share=False)
|
|
|
|
| 200 |
logging.error(f"Detection failed: {str(e)}")
|
| 201 |
return None, f"Detection failed: {str(e)}"
|
| 202 |
|
| 203 |
+
# Use gr.Blocks for more control over the UI
|
| 204 |
+
with gr.Blocks() as demo:
|
| 205 |
+
gr.Markdown(
|
| 206 |
+
"""
|
| 207 |
+
# Structural Defect Detection with Salesforce Integration
|
| 208 |
+
Upload drone-captured images to detect structural defects like cracks, rust, spalling, and deformations using Faster R-CNN. Detected faults are stored in Salesforce with annotated images.
|
| 209 |
+
"""
|
| 210 |
+
)
|
| 211 |
+
with gr.Row():
|
| 212 |
+
image_input = gr.Image(type="pil", label="Upload Drone Image")
|
| 213 |
+
image_output = gr.Image(label="Detection Result")
|
| 214 |
+
output_text = gr.Textbox(label="Detected Faults with Severity")
|
| 215 |
+
with gr.Row():
|
| 216 |
+
clear_btn = gr.Button("Clear")
|
| 217 |
+
submit_btn = gr.Button("Submit", variant="primary")
|
| 218 |
+
|
| 219 |
+
submit_btn.click(
|
| 220 |
+
fn=detect_defects,
|
| 221 |
+
inputs=image_input,
|
| 222 |
+
outputs=[image_output, output_text]
|
| 223 |
+
)
|
| 224 |
+
clear_btn.click(
|
| 225 |
+
fn=lambda: (None, ""),
|
| 226 |
+
inputs=None,
|
| 227 |
+
outputs=[image_input, output_text]
|
| 228 |
)
|
|
|
|
| 229 |
|
| 230 |
if __name__ == "__main__":
|
| 231 |
+
demo.launch(share=False, allow_flagging="never")
|