capradeepgujaran commited on
Commit
30f4028
1 Parent(s): 49a323c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- from gradio.components import Image, Textbox, Markdown
3
  import cv2
4
  import numpy as np
5
  from groq import Groq
@@ -72,7 +71,7 @@ def create_monitor_interface():
72
 
73
  def process_frame(self, frame: np.ndarray) -> tuple[np.ndarray, str]:
74
  if frame is None:
75
- return None, "No frame received"
76
 
77
  analysis = self.analyze_frame(frame)
78
  display_frame = frame.copy()
@@ -94,13 +93,16 @@ def create_monitor_interface():
94
  monitor = SafetyMonitor()
95
 
96
  with gr.Blocks() as demo:
97
- gr.Markdown("# Real-time Safety Monitoring System")
 
 
 
98
 
99
  with gr.Row():
100
- input_image = Image(label="Input Image", type="numpy", tool="upload")
101
- output_image = Image(label="Analysis Feed", type="numpy")
102
 
103
- analysis_text = Textbox(label="Safety Analysis", lines=5)
104
 
105
  def analyze_image(image):
106
  if image is None:
@@ -110,15 +112,15 @@ def create_monitor_interface():
110
 
111
  input_image.change(
112
  fn=analyze_image,
113
- inputs=[input_image],
114
- outputs=[output_image, analysis_text],
115
  )
116
 
117
  gr.Markdown("""
118
  ## Instructions:
119
- 1. Upload an image using the input panel
120
- 2. The system will automatically analyze the image for safety concerns
121
- 3. Results will be shown in the analysis feed and text box
122
  """)
123
 
124
  return demo
 
1
  import gradio as gr
 
2
  import cv2
3
  import numpy as np
4
  from groq import Groq
 
71
 
72
  def process_frame(self, frame: np.ndarray) -> tuple[np.ndarray, str]:
73
  if frame is None:
74
+ return None, "No image provided"
75
 
76
  analysis = self.analyze_frame(frame)
77
  display_frame = frame.copy()
 
93
  monitor = SafetyMonitor()
94
 
95
  with gr.Blocks() as demo:
96
+ gr.Markdown("""
97
+ # Real-time Safety Monitoring System
98
+ Upload an image to analyze workplace safety concerns.
99
+ """)
100
 
101
  with gr.Row():
102
+ input_image = gr.Image(label="Upload Image")
103
+ output_image = gr.Image(label="Analysis Results")
104
 
105
+ analysis_text = gr.Textbox(label="Safety Analysis", lines=5)
106
 
107
  def analyze_image(image):
108
  if image is None:
 
112
 
113
  input_image.change(
114
  fn=analyze_image,
115
+ inputs=input_image,
116
+ outputs=[output_image, analysis_text]
117
  )
118
 
119
  gr.Markdown("""
120
  ## Instructions:
121
+ 1. Click the 'Upload Image' area or drag and drop an image
122
+ 2. The system will automatically analyze the safety concerns
123
+ 3. View the analyzed image and detailed safety report
124
  """)
125
 
126
  return demo