Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -136,50 +136,20 @@ def set_active_service(
|
|
136 |
logging.info("No service category enabled.")
|
137 |
return None, "No Service Category Enabled"
|
138 |
|
139 |
-
def generate_line_chart():
|
140 |
if not crack_counts:
|
141 |
return None
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
"pointBackgroundColor": "#3CB371",
|
154 |
-
"pointRadius": 5
|
155 |
-
}]
|
156 |
-
},
|
157 |
-
"options": {
|
158 |
-
"responsive": false,
|
159 |
-
"scales": {
|
160 |
-
"x": {
|
161 |
-
"title": {
|
162 |
-
"display": true,
|
163 |
-
"text": "Frame"
|
164 |
-
}
|
165 |
-
},
|
166 |
-
"y": {
|
167 |
-
"title": {
|
168 |
-
"display": true,
|
169 |
-
"text": "Count of Cracks/Holes"
|
170 |
-
}
|
171 |
-
}
|
172 |
-
},
|
173 |
-
"title": {
|
174 |
-
"display": true,
|
175 |
-
"text": "Cracks/Holes Over Time"
|
176 |
-
}
|
177 |
-
}
|
178 |
-
}
|
179 |
-
```
|
180 |
-
|
181 |
-
def generate_map(gps_coordinates: List[List[float]], items: List[Dict]]) -> Optional[str]:
|
182 |
-
return generate_map(gps_coordinates, items)
|
183 |
|
184 |
def monitor_feed() -> Tuple[
|
185 |
Optional[np.ndarray],
|
@@ -188,19 +158,13 @@ def monitor_feed() -> Tuple[
|
|
188 |
List[str],
|
189 |
List[str],
|
190 |
Optional[str],
|
191 |
-
|
192 |
-
|
193 |
-
frame_count,
|
194 |
-
|
195 |
-
last_metrics,
|
196 |
-
last_timestamp,
|
197 |
-
gps_coordinates,
|
198 |
-
last_detected_cracks,
|
199 |
-
last_detected_holes,
|
200 |
-
video_loaded
|
201 |
|
202 |
if not video_loaded:
|
203 |
-
log_entries.append(
|
204 |
logging.error("Video not loaded successfully.")
|
205 |
return (
|
206 |
None,
|
|
|
136 |
logging.info("No service category enabled.")
|
137 |
return None, "No Service Category Enabled"
|
138 |
|
139 |
+
def generate_line_chart() -> Optional[str]:
|
140 |
if not crack_counts:
|
141 |
return None
|
142 |
+
fig, ax = plt.subplots(figsize=(4, 2))
|
143 |
+
ax.plot(crack_counts[-50:], marker='o', color='#4682B4')
|
144 |
+
ax.set_title("Cracks/Holes Over Time")
|
145 |
+
ax.set_xlabel("Frame")
|
146 |
+
ax.set_ylabel("Count")
|
147 |
+
ax.grid(True)
|
148 |
+
fig.tight_layout()
|
149 |
+
chart_path = "chart_temp.png"
|
150 |
+
fig.savefig(chart_path)
|
151 |
+
plt.close(fig)
|
152 |
+
return chart_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
def monitor_feed() -> Tuple[
|
155 |
Optional[np.ndarray],
|
|
|
158 |
List[str],
|
159 |
List[str],
|
160 |
Optional[str],
|
161 |
+
Optional[str]
|
162 |
+
]:
|
163 |
+
global paused, frame_count, last_frame, last_metrics, last_timestamp
|
164 |
+
global gps_coordinates, last_detected_cracks, last_detected_holes, video_loaded
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
166 |
if not video_loaded:
|
167 |
+
log_entries.append("Cannot start streaming: Video not loaded successfully.")
|
168 |
logging.error("Video not loaded successfully.")
|
169 |
return (
|
170 |
None,
|