Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
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
|
146 |
with gr.Blocks(theme=gr.themes.Soft(), css="""
|
147 |
-
body {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
.gr-button {
|
149 |
margin: 5px;
|
150 |
-
background
|
151 |
color: white;
|
152 |
border: none;
|
153 |
-
border-radius:
|
154 |
-
padding:
|
155 |
-
transition:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
-
.gr-
|
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:
|
163 |
-
padding:
|
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:
|
172 |
background-color: #2b2b2b;
|
173 |
-
box-shadow: 0 4px
|
174 |
}
|
175 |
.legend {
|
176 |
-
background
|
177 |
-
padding:
|
178 |
-
border-radius:
|
179 |
-
margin-bottom:
|
180 |
border: 1px solid #444;
|
|
|
181 |
}
|
182 |
-
.legend span { margin-right:
|
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 |
|