lokesh341 commited on
Commit
8053086
·
verified ·
1 Parent(s): 2933e05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -53
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
- ```chartjs
143
- {
144
- "type": "line",
145
- "data": {
146
- "labels": [i for i in range(len(crack_counts[-50:]))],
147
- "datasets": [{
148
- "label": crack_counts[-50:],
149
- "data": crack_counts[-50:],
150
- "borderColor": "#4682B4",
151
- "backgroundColor": "#4682B4",
152
- "fill": false,
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
- global
192
- paused,
193
- frame_count,
194
- last_frame,
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(("Cannot start streaming: Video not loaded successfully.")
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,