nagasurendra commited on
Commit
fbd4a06
·
verified ·
1 Parent(s): d740c19

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +142 -142
app.py CHANGED
@@ -204,175 +204,175 @@ def generate_report(
204
  avg_inference_time = sum(inference_times) / len(inference_times) if inference_times else 0
205
  avg_io_time = sum(io_times) / len(io_times) if io_times else 0
206
 
207
- # LaTeX template
208
  latex_template = r"""
209
- \documentclass[a4paper,12pt]{article}
210
- \usepackage[utf8]{inputenc}
211
- \usepackage[T1]{fontenc}
212
- \usepackage{geometry}
213
- \geometry{margin=1in}
214
- \usepackage{graphicx}
215
- \usepackage{booktabs}
216
- \usepackage{longtable}
217
- \usepackage{hyperref}
218
- \usepackage{xcolor}
219
- \usepackage{parskip}
220
- \setlength{\parskip}{0.5em}
221
- \usepackage{noto}
222
- \graphicspath{{./captured_frames/}}
223
-
224
- \begin{document}
225
 
226
  % Title and project details
227
- \section*{NHAI Drone Survey Analysis Report}
228
-
229
- \subsection*{Project Details}
230
- \begin{itemize}
231
- \item \textbf{Project Name:} NH-44 Delhi-Hyderabad Section (Package XYZ)
232
- \item \textbf{Highway Section:} Km 100 to Km 150
233
- \item \textbf{State:} Telangana
234
- \item \textbf{Region:} South
235
- \item \textbf{Survey Date:} \today
236
- \item \textbf{Drone Service Provider:} ABC Drone Services Pvt. Ltd.
237
- \item \textbf{Technology Service Provider:} XYZ AI Analytics Ltd.
238
- \item \textbf{Work Order Reference:} Data Lake WO-\today-XYZ
239
- \item \textbf{Report Prepared By:} Nagasurendra, Data Analyst
240
- \item \textbf{Report Date:} \today
241
- \end{itemize}
242
-
243
- \section{Introduction}
244
  This report consolidates drone survey results for NH-44 (Km 100--150) under Operations \& Maintenance, per NHAI Policy Circular No. 18.98/2024, detecting potholes and cracks using YOLOv8 for Monthly Progress Report integration.
245
 
246
- \section{Drone Survey Metadata}
247
- \begin{itemize}
248
- \item \textbf{Drone Speed:} 5 m/s
249
- \item \textbf{Drone Height:} 60 m
250
- \item \textbf{Camera Sensor:} RGB, 12 MP
251
- \item \textbf{Recording Type:} JPEG, 90° nadir
252
- \item \textbf{Image Overlap:} 85\%
253
- \item \textbf{Flight Pattern:} Single lap, ROW centered
254
- \item \textbf{Geotagging:} Enabled
255
- \item \textbf{Satellite Lock:} 12 satellites
256
- \item \textbf{Terrain Follow Mode:} Enabled
257
- \end{itemize}
258
-
259
- \section{Quality Check Results}
260
- \begin{itemize}
261
- \item \textbf{Resolution:} 4000x3000 (12 MP)
262
- \item \textbf{Overlap:} 85\%
263
- \item \textbf{Camera Angle:} 90° nadir
264
- \item \textbf{Drone Speed:} $\leq$ 5 m/s
265
- \item \textbf{Geotagging:} 100\% compliant
266
- \item \textbf{QC Status:} Passed
267
- \end{itemize}
268
-
269
- \section{AI/ML Analytics}
270
- \begin{itemize}
271
- \item \textbf{Total Frames Processed:} {frame_count}
272
- \item \textbf{Detection Frames:} {detection_frame_count} ({detection_percentage:.2f}\%)
273
- \item \textbf{Total Detections:} {total_detections}
274
- \item \textbf{Breakdown:}
275
- \begin{itemize}
276
  {items}
277
- \end{itemize}
278
- \item \textbf{Processing Time:} {total_time:.2f} seconds
279
- \item \textbf{Average Frame Time:} {avg_frame_time:.2f} ms
280
- \item \textbf{Average Resize Time:} {avg_resize_time:.2f} ms
281
- \item \textbf{Average Inference Time:} {avg_inference_time:.2f} ms
282
- \item \textbf{Average I/O Time:} {avg_io_time:.2f} ms
283
- \item \textbf{Timestamp:} {timestamp_str}
284
- \item \textbf{Summary:} Potholes and cracks detected in high-traffic segments.
285
- \end{itemize}
286
-
287
- \section{Output File Structure}
288
- \begin{itemize}
289
  \item ZIP file contains:
290
- \begin{itemize}
291
- \item \texttt{drone_analysis_report_{timestamp}.pdf}: This report
292
- \item \texttt{outputs/processed_output.mp4}: Processed video with annotations
293
- \item \texttt{outputs/chart_{timestamp}.png}: Detection trend chart
294
- \item \texttt{outputs/map_{timestamp}.png}: Issue locations map
295
- \item \texttt{captured_frames/detected_<frame>.jpg}: Geotagged images for detected issues
296
- \item \texttt{flight_logs/flight_log_<frame>.csv}: Flight logs matching image frames
297
- \end{itemize}
298
- \item \textbf{Note:} Images and logs share frame numbers (e.g., \texttt{detected_000001.jpg} corresponds to \texttt{flight_log_000001.csv}).
299
- \end{itemize}
300
-
301
- \section{Geotagged Images}
302
- \begin{itemize}
303
- \item \textbf{Total Images:} {total_images}
304
- \item \textbf{Storage:} Data Lake \texttt{{/project_xyz/images/{date_str}}}
305
- \end{itemize}
306
-
307
- \begin{longtable}{c l c c c p{4cm}}
308
  \toprule
309
- \textbf{Frame} & \textbf{Issue Type} & \textbf{GPS (Lat, Lon)} & \textbf{Timestamp} & \textbf{Confidence} & \textbf{Image} \\
310
  \midrule
311
  \endhead
312
  {image_rows}
313
  \bottomrule
314
- \end{longtable}
315
 
316
- \section{Flight Logs}
317
- \begin{itemize}
318
- \item \textbf{Total Logs:} {total_logs}
319
- \item \textbf{Storage:} Data Lake \texttt{{/project_xyz/flight_logs/{date_str}}}
320
- \end{itemize}
321
 
322
- \begin{longtable}{c c c c c c c l}
323
  \toprule
324
- \textbf{Frame} & \textbf{Timestamp} & \textbf{Latitude} & \textbf{Longitude} & \textbf{Speed (m/s)} & \textbf{Satellites} & \textbf{Altitude (m)} & \textbf{Log Path} \\
325
  \midrule
326
  \endhead
327
  {log_rows}
328
  \bottomrule
329
- \end{longtable}
330
-
331
- \section{Processed Video}
332
- \begin{itemize}
333
- \item \textbf{Path:} \texttt{outputs/processed_output.mp4}
334
- \item \textbf{Frames:} {output_frames}
335
- \item \textbf{FPS:} {output_fps:.2f}
336
- \item \textbf{Duration:} {output_duration:.2f} seconds
337
- \end{itemize}
338
-
339
- \section{Visualizations}
340
- \begin{itemize}
341
- \item \textbf{Detection Trend Chart:} \texttt{outputs/chart_{timestamp}.png}
342
- \item \textbf{Issue Locations Map:} \texttt{outputs/map_{timestamp}.png}
343
- \end{itemize}
344
-
345
- \section{Processing Timestamps}
346
- \begin{itemize}
347
- \item \textbf{Total Processing Time:} {total_time:.2f} seconds
348
- \item \textbf{Log Entries (Last 10):}
349
- \begin{itemize}
350
  {log_entries}
351
- \end{itemize}
352
- \end{itemize}
353
 
354
- \section{Stakeholder Validation}
355
- \begin{itemize}
356
- \item \textbf{AE/IE Comments:} [Pending]
357
- \item \textbf{PD/RO Comments:} [Pending]
358
- \end{itemize}
359
 
360
- \section{Recommendations}
361
- \begin{itemize}
362
  \item Repair potholes in high-traffic segments.
363
  \item Seal cracks to prevent degradation.
364
  \item Schedule follow-up survey.
365
- \end{itemize}
366
 
367
- \section{Data Lake References}
368
- \begin{itemize}
369
- \item \textbf{Images:} \texttt{{/project_xyz/images/{date_str}}}
370
- \item \textbf{Flight Logs:} \texttt{{/project_xyz/flight_logs/{date_str}}}
371
- \item \textbf{Video:} \texttt{{/project_xyz/videos/processed_output_{date_str_no_dash}.mp4}}
372
- \item \textbf{DAMS Dashboard:} \texttt{{/project_xyz/dams/{date_str}}}
373
- \end{itemize}
374
 
375
- \end{document}
376
  """
377
 
378
  # Format the LaTeX template
 
204
  avg_inference_time = sum(inference_times) / len(inference_times) if inference_times else 0
205
  avg_io_time = sum(io_times) / len(io_times) if io_times else 0
206
 
207
+ # LaTeX template with escaped curly braces
208
  latex_template = r"""
209
+ \documentclass[a4paper,12pt]{{article}}
210
+ \usepackage[utf8]{{inputenc}}
211
+ \usepackage[T1]{{fontenc}}
212
+ \usepackage{{geometry}}
213
+ \geometry{{margin=1in}}
214
+ \usepackage{{graphicx}}
215
+ \usepackage{{booktabs}}
216
+ \usepackage{{longtable}}
217
+ \usepackage{{hyperref}}
218
+ \usepackage{{xcolor}}
219
+ \usepackage{{parskip}}
220
+ \setlength{{\parskip}}{{0.5em}}
221
+ \usepackage{{noto}}
222
+ \graphicspath{{{{./captured_frames/}}}}
223
+
224
+ \begin{{document}}
225
 
226
  % Title and project details
227
+ \section*{{NHAI Drone Survey Analysis Report}}
228
+
229
+ \subsection*{{Project Details}}
230
+ \begin{{itemize}}
231
+ \item \textbf{{Project Name:}} NH-44 Delhi-Hyderabad Section (Package XYZ)
232
+ \item \textbf{{Highway Section:}} Km 100 to Km 150
233
+ \item \textbf{{State:}} Telangana
234
+ \item \textbf{{Region:}} South
235
+ \item \textbf{{Survey Date:}} \today
236
+ \item \textbf{{Drone Service Provider:}} ABC Drone Services Pvt. Ltd.
237
+ \item \textbf{{Technology Service Provider:}} XYZ AI Analytics Ltd.
238
+ \item \textbf{{Work Order Reference:}} Data Lake WO-\today-XYZ
239
+ \item \textbf{{Report Prepared By:}} Nagasurendra, Data Analyst
240
+ \item \textbf{{Report Date:}} \today
241
+ \end{{itemize}}
242
+
243
+ \section{{Introduction}}
244
  This report consolidates drone survey results for NH-44 (Km 100--150) under Operations \& Maintenance, per NHAI Policy Circular No. 18.98/2024, detecting potholes and cracks using YOLOv8 for Monthly Progress Report integration.
245
 
246
+ \section{{Drone Survey Metadata}}
247
+ \begin{{itemize}}
248
+ \item \textbf{{Drone Speed:}} 5 m/s
249
+ \item \textbf{{Drone Height:}} 60 m
250
+ \item \textbf{{Camera Sensor:}} RGB, 12 MP
251
+ \item \textbf{{Recording Type:}} JPEG, 90° nadir
252
+ \item \textbf{{Image Overlap:}} 85\%
253
+ \item \textbf{{Flight Pattern:}} Single lap, ROW centered
254
+ \item \textbf{{Geotagging:}} Enabled
255
+ \item \textbf{{Satellite Lock:}} 12 satellites
256
+ \item \textbf{{Terrain Follow Mode:}} Enabled
257
+ \end{{itemize}}
258
+
259
+ \section{{Quality Check Results}}
260
+ \begin{{itemize}}
261
+ \item \textbf{{Resolution:}} 4000x3000 (12 MP)
262
+ \item \textbf{{Overlap:}} 85\%
263
+ \item \textbf{{Camera Angle:}} 90° nadir
264
+ \item \textbf{{Drone Speed:}} $\leq$ 5 m/s
265
+ \item \textbf{{Geotagging:}} 100\% compliant
266
+ \item \textbf{{QC Status:}} Passed
267
+ \end{{itemize}}
268
+
269
+ \section{{AI/ML Analytics}}
270
+ \begin{{itemize}}
271
+ \item \textbf{{Total Frames Processed:}} {frame_count}
272
+ \item \textbf{{Detection Frames:}} {detection_frame_count} ({detection_percentage:.2f}\%)
273
+ \item \textbf{{Total Detections:}} {total_detections}
274
+ \item \textbf{{Breakdown:}}
275
+ \begin{{itemize}}
276
  {items}
277
+ \end{{itemize}}
278
+ \item \textbf{{Processing Time:}} {total_time:.2f} seconds
279
+ \item \textbf{{Average Frame Time:}} {avg_frame_time:.2f} ms
280
+ \item \textbf{{Average Resize Time:}} {avg_resize_time:.2f} ms
281
+ \item \textbf{{Average Inference Time:}} {avg_inference_time:.2f} ms
282
+ \item \textbf{{Average I/O Time:}} {avg_io_time:.2f} ms
283
+ \item \textbf{{Timestamp:}} {timestamp_str}
284
+ \item \textbf{{Summary:}} Potholes and cracks detected in high-traffic segments.
285
+ \end{{itemize}}
286
+
287
+ \section{{Output File Structure}}
288
+ \begin{{itemize}}
289
  \item ZIP file contains:
290
+ \begin{{itemize}}
291
+ \item \texttt{{drone_analysis_report_{timestamp}.pdf}}: This report
292
+ \item \texttt{{outputs/processed_output.mp4}}: Processed video with annotations
293
+ \item \texttt{{outputs/chart_{timestamp}.png}}: Detection trend chart
294
+ \item \texttt{{outputs/map_{timestamp}.png}}: Issue locations map
295
+ \item \texttt{{captured_frames/detected_<frame>.jpg}}: Geotagged images for detected issues
296
+ \item \texttt{{flight_logs/flight_log_<frame>.csv}}: Flight logs matching image frames
297
+ \end{{itemize}}
298
+ \item \textbf{{Note:}} Images and logs share frame numbers (e.g., \texttt{{detected_000001.jpg}} corresponds to \texttt{{flight_log_000001.csv}}).
299
+ \end{{itemize}}
300
+
301
+ \section{{Geotagged Images}}
302
+ \begin{{itemize}}
303
+ \item \textbf{{Total Images:}} {total_images}
304
+ \item \textbf{{Storage:}} Data Lake \texttt{{/project_xyz/images/{date_str}}}
305
+ \end{{itemize}}
306
+
307
+ \begin{{longtable}}{{c l c c c p{{4cm}}}}
308
  \toprule
309
+ \textbf{{Frame}} & \textbf{{Issue Type}} & \textbf{{GPS (Lat, Lon)}} & \textbf{{Timestamp}} & \textbf{{Confidence}} & \textbf{{Image}} \\
310
  \midrule
311
  \endhead
312
  {image_rows}
313
  \bottomrule
314
+ \end{{longtable}}
315
 
316
+ \section{{Flight Logs}}
317
+ \begin{{itemize}}
318
+ \item \textbf{{Total Logs:}} {total_logs}
319
+ \item \textbf{{Storage:}} Data Lake \texttt{{/project_xyz/flight_logs/{date_str}}}
320
+ \end{{itemize}}
321
 
322
+ \begin{{longtable}}{{c c c c c c c l}}
323
  \toprule
324
+ \textbf{{Frame}} & \textbf{{Timestamp}} & \textbf{{Latitude}} & \textbf{{Longitude}} & \textbf{{Speed (m/s)}} & \textbf{{Satellites}} & \textbf{{Altitude (m)}} & \textbf{{Log Path}} \\
325
  \midrule
326
  \endhead
327
  {log_rows}
328
  \bottomrule
329
+ \end{{longtable}}
330
+
331
+ \section{{Processed Video}}
332
+ \begin{{itemize}}
333
+ \item \textbf{{Path:}} \texttt{{outputs/processed_output.mp4}}
334
+ \item \textbf{{Frames:}} {output_frames}
335
+ \item \textbf{{FPS:}} {output_fps:.2f}
336
+ \item \textbf{{Duration:}} {output_duration:.2f} seconds
337
+ \end{{itemize}}
338
+
339
+ \section{{Visualizations}}
340
+ \begin{{itemize}}
341
+ \item \textbf{{Detection Trend Chart:}} \texttt{{outputs/chart_{timestamp}.png}}
342
+ \item \textbf{{Issue Locations Map:}} \texttt{{outputs/map_{timestamp}.png}}
343
+ \end{{itemize}}
344
+
345
+ \section{{Processing Timestamps}}
346
+ \begin{{itemize}}
347
+ \item \textbf{{Total Processing Time:}} {total_time:.2f} seconds
348
+ \item \textbf{{Log Entries (Last 10):}}
349
+ \begin{{itemize}}
350
  {log_entries}
351
+ \end{{itemize}}
352
+ \end{{itemize}}
353
 
354
+ \section{{Stakeholder Validation}}
355
+ \begin{{itemize}}
356
+ \item \textbf{{AE/IE Comments:}} [Pending]
357
+ \item \textbf{{PD/RO Comments:}} [Pending]
358
+ \end{{itemize}}
359
 
360
+ \section{{Recommendations}}
361
+ \begin{{itemize}}
362
  \item Repair potholes in high-traffic segments.
363
  \item Seal cracks to prevent degradation.
364
  \item Schedule follow-up survey.
365
+ \end{{itemize}}
366
 
367
+ \section{{Data Lake References}}
368
+ \begin{{itemize}}
369
+ \item \textbf{{Images:}} \texttt{{/project_xyz/images/{date_str}}}
370
+ \item \textbf{{Flight Logs:}} \texttt{{/project_xyz/flight_logs/{date_str}}}
371
+ \item \textbf{{Video:}} \texttt{{/project_xyz/videos/processed_output_{date_str_no_dash}.mp4}}
372
+ \item \textbf{{DAMS Dashboard:}} \texttt{{/project_xyz/dams/{date_str}}}
373
+ \end{{itemize}}
374
 
375
+ \end{{document}}
376
  """
377
 
378
  # Format the LaTeX template