Update app.py
Browse files
app.py
CHANGED
|
@@ -96,21 +96,21 @@ def create_monitor_interface():
|
|
| 96 |
gr.Markdown("# Real-time Safety Monitoring System")
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
-
webcam = gr.
|
| 100 |
output_image = gr.Image(label="Analysis Feed")
|
| 101 |
|
| 102 |
analysis_text = gr.Textbox(label="Safety Analysis", lines=5)
|
| 103 |
|
| 104 |
-
def analyze_stream(
|
| 105 |
-
if
|
| 106 |
return None, "Webcam not started"
|
| 107 |
-
processed_frame, analysis = monitor.process_frame(
|
| 108 |
return processed_frame, analysis
|
| 109 |
|
| 110 |
-
webcam.
|
| 111 |
fn=analyze_stream,
|
|
|
|
| 112 |
outputs=[output_image, analysis_text],
|
| 113 |
-
show_progress=False
|
| 114 |
)
|
| 115 |
|
| 116 |
return demo
|
|
|
|
| 96 |
gr.Markdown("# Real-time Safety Monitoring System")
|
| 97 |
|
| 98 |
with gr.Row():
|
| 99 |
+
webcam = gr.Webcam(label="Webcam Feed")
|
| 100 |
output_image = gr.Image(label="Analysis Feed")
|
| 101 |
|
| 102 |
analysis_text = gr.Textbox(label="Safety Analysis", lines=5)
|
| 103 |
|
| 104 |
+
def analyze_stream(image):
|
| 105 |
+
if image is None:
|
| 106 |
return None, "Webcam not started"
|
| 107 |
+
processed_frame, analysis = monitor.process_frame(image)
|
| 108 |
return processed_frame, analysis
|
| 109 |
|
| 110 |
+
webcam.change(
|
| 111 |
fn=analyze_stream,
|
| 112 |
+
inputs=[webcam],
|
| 113 |
outputs=[output_image, analysis_text],
|
|
|
|
| 114 |
)
|
| 115 |
|
| 116 |
return demo
|