Komal133 commited on
Commit
39f18c1
·
verified ·
1 Parent(s): 1df0791

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -13
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
- demo = gr.Interface(
204
- fn=detect_defects,
205
- inputs=gr.Image(type="pil", label="Upload Drone Image"),
206
- outputs=[
207
- gr.Image(label="Detection Result"),
208
- gr.Textbox(label="Detected Faults with Severity")
209
- ],
210
- title="Structural Defect Detection with Salesforce Integration",
211
- description=(
212
- "Upload drone-captured images to detect structural defects like cracks, rust, spalling, "
213
- "and deformations using Faster R-CNN. Detected faults are stored in Salesforce with annotated images."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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")