lokesh341 commited on
Commit
ed72d72
·
verified ·
1 Parent(s): 1552777

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -19
app.py CHANGED
@@ -63,7 +63,10 @@ def monitor_feed():
63
  obj_id = item['id']
64
  if obj_id not in state.detected_ids:
65
  captured_frame_path = os.path.join(state.CAPTURED_FRAMES_DIR, f"{item['type']}_ID{obj_id}.jpg")
66
- cv2.imwrite(captured_frame_path, frame)
 
 
 
67
  state.detected_ids.add(obj_id)
68
  if captured_frame_path not in state.last_detected_images:
69
  state.last_detected_images.append(captured_frame_path)
@@ -142,44 +145,73 @@ def monitor_feed():
142
 
143
  return frame[:, :, ::-1], metrics, "\n".join(state.log_entries[-10:]), line_chart_html, pie_chart_html, state.last_detected_images, map_html
144
 
145
- # Gradio UI with improved UI/UX
146
  with gr.Blocks(theme=gr.themes.Soft(), css="""
147
- body { background-color: #1a1a1a; color: #ffffff; font-family: 'Arial', sans-serif; }
 
 
 
 
 
 
 
 
 
 
 
 
148
  .gr-button {
149
  margin: 5px;
150
- background-color: #ff4d4d;
151
  color: white;
152
  border: none;
153
- border-radius: 8px;
154
- padding: 10px 20px;
155
- transition: background-color 0.3s;
 
 
 
 
 
 
 
 
 
 
156
  }
157
- .gr-button:hover { background-color: #ff6666; }
158
- .gr-image { border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
159
  .gr-textbox, .gr-html {
160
  background-color: #2b2b2b;
161
  border: 1px solid #444;
162
- border-radius: 8px;
163
- padding: 10px;
164
  color: #ffffff;
 
 
 
 
 
 
 
 
165
  }
166
- #map-output { height: 400px; width: 100%; border: 1px solid #444; border-radius: 8px; box-shadow: 0 4px 8px rgba(0,0,0,0.3); }
167
  #chart-output, #pie-output {
168
  height: 200px;
169
  width: 100%;
170
  border: 1px solid #444;
171
- border-radius: 8px;
172
  background-color: #2b2b2b;
173
- box-shadow: 0 4px 8px rgba(0,0,0,0.3);
174
  }
175
  .legend {
176
- background-color: #2b2b2b;
177
- padding: 10px;
178
- border-radius: 8px;
179
- margin-bottom: 10px;
180
  border: 1px solid #444;
 
181
  }
182
- .legend span { margin-right: 15px; font-size: 14px; }
183
  """) as app:
184
  gr.Markdown("# 🛡️ Drone Road Inspection Dashboard", elem_classes="header")
185
 
 
63
  obj_id = item['id']
64
  if obj_id not in state.detected_ids:
65
  captured_frame_path = os.path.join(state.CAPTURED_FRAMES_DIR, f"{item['type']}_ID{obj_id}.jpg")
66
+ # Ensure the frame saved to disk has the same markings as the live feed
67
+ marked_frame = frame.copy()
68
+ marked_frame = overlay_boxes(marked_frame, [item])
69
+ cv2.imwrite(captured_frame_path, marked_frame)
70
  state.detected_ids.add(obj_id)
71
  if captured_frame_path not in state.last_detected_images:
72
  state.last_detected_images.append(captured_frame_path)
 
145
 
146
  return frame[:, :, ::-1], metrics, "\n".join(state.log_entries[-10:]), line_chart_html, pie_chart_html, state.last_detected_images, map_html
147
 
148
+ # Gradio UI with beautiful design
149
  with gr.Blocks(theme=gr.themes.Soft(), css="""
150
+ body {
151
+ background: linear-gradient(135deg, #1a1a1a, #2b2b2b);
152
+ color: #ffffff;
153
+ font-family: 'Poppins', sans-serif;
154
+ }
155
+ .header {
156
+ font-size: 2em;
157
+ text-align: center;
158
+ background: linear-gradient(90deg, #ff4d4d, #ff6666);
159
+ -webkit-background-clip: text;
160
+ -webkit-text-fill-color: transparent;
161
+ margin-bottom: 20px;
162
+ }
163
  .gr-button {
164
  margin: 5px;
165
+ background: linear-gradient(90deg, #ff4d4d, #ff6666);
166
  color: white;
167
  border: none;
168
+ border-radius: 12px;
169
+ padding: 12px 24px;
170
+ transition: transform 0.2s, box-shadow 0.2s;
171
+ box-shadow: 0 4px 12px rgba(255, 77, 77, 0.3);
172
+ }
173
+ .gr-button:hover {
174
+ transform: translateY(-2px);
175
+ box-shadow: 0 6px 16px rgba(255, 77, 77, 0.5);
176
+ }
177
+ .gr-image {
178
+ border-radius: 12px;
179
+ box-shadow: 0 4px 12px rgba(0,0,0,0.4);
180
+ transition: transform 0.3s;
181
  }
182
+ .gr-image:hover { transform: scale(1.02); }
 
183
  .gr-textbox, .gr-html {
184
  background-color: #2b2b2b;
185
  border: 1px solid #444;
186
+ border-radius: 12px;
187
+ padding: 15px;
188
  color: #ffffff;
189
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
190
+ }
191
+ #map-output {
192
+ height: 400px;
193
+ width: 100%;
194
+ border: 1px solid #444;
195
+ border-radius: 12px;
196
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
197
  }
 
198
  #chart-output, #pie-output {
199
  height: 200px;
200
  width: 100%;
201
  border: 1px solid #444;
202
+ border-radius: 12px;
203
  background-color: #2b2b2b;
204
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
205
  }
206
  .legend {
207
+ background: linear-gradient(135deg, #2b2b2b, #3b3b3b);
208
+ padding: 15px;
209
+ border-radius: 12px;
210
+ margin-bottom: 15px;
211
  border: 1px solid #444;
212
+ box-shadow: 0 4px 12px rgba(0,0,0,0.3);
213
  }
214
+ .legend span { margin-right: 20px; font-size: 16px; font-weight: 500; }
215
  """) as app:
216
  gr.Markdown("# 🛡️ Drone Road Inspection Dashboard", elem_classes="header")
217