Yaswanth56 commited on
Commit
f768b0c
·
verified ·
1 Parent(s): 2c8e46e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -44,39 +44,44 @@ model = YOLO('./data/best.pt').to(device)
44
  if device == "cuda":
45
  model.half()
46
 
47
- # Function to generate the PDF report with images and data
48
  def generate_pdf_report(summary: str, screenshots: List[str], log_results: List[str], chart_path: str, map_path: str, pdf_path: str):
49
  c = canvas.Canvas(pdf_path, pagesize=letter)
50
  width, height = letter
51
 
52
- # Title
53
  c.setFont("Helvetica", 16)
54
  c.drawString(72, height - 72, "Drone Survey Analysis Report")
 
55
 
56
- # Add summary text
57
  c.setFont("Helvetica", 12)
58
- c.drawString(72, height - 100, "Summary:")
59
- c.drawString(72, height - 120, summary)
 
60
 
61
- # Add Logs for Top 5 Images
62
- c.drawString(72, height - 160, "Log Results for Top 5 Images:")
63
- y_position = height - 180
64
  for log in log_results[:5]: # Display top 5 logs
65
  c.drawString(72, y_position, log)
66
  y_position -= 15
 
67
 
68
- # Add Screenshots (Top 5 Images)
69
  c.drawString(72, y_position - 20, "Incident Screenshots:")
70
  y_position -= 40
71
  for screenshot in screenshots[:5]: # Limit to the top 5 images
72
  c.drawImage(screenshot, 72, y_position, width=150, height=100)
73
  y_position -= 120
 
74
 
75
- # Add Chart Image
76
  c.drawString(72, y_position - 20, "Detection Trend Chart:")
77
  c.drawImage(chart_path, 72, y_position - 100, width=400, height=300)
 
78
 
79
- # Add Map Image
80
  c.drawString(72, y_position - 140, "Issue Locations Map:")
81
  c.drawImage(map_path, 72, y_position - 240, width=400, height=300)
82
 
 
44
  if device == "cuda":
45
  model.half()
46
 
47
+ # Function to generate the PDF report with images and data, each section on a new page
48
  def generate_pdf_report(summary: str, screenshots: List[str], log_results: List[str], chart_path: str, map_path: str, pdf_path: str):
49
  c = canvas.Canvas(pdf_path, pagesize=letter)
50
  width, height = letter
51
 
52
+ # Title Page
53
  c.setFont("Helvetica", 16)
54
  c.drawString(72, height - 72, "Drone Survey Analysis Report")
55
+ c.showPage() # Create a new page
56
 
57
+ # Add Summary Text (New Page)
58
  c.setFont("Helvetica", 12)
59
+ c.drawString(72, height - 72, "Summary:")
60
+ c.drawString(72, height - 92, summary)
61
+ c.showPage() # Create a new page
62
 
63
+ # Add Logs for Top 5 Images (New Page)
64
+ c.drawString(72, height - 72, "Log Results for Top 5 Images:")
65
+ y_position = height - 92
66
  for log in log_results[:5]: # Display top 5 logs
67
  c.drawString(72, y_position, log)
68
  y_position -= 15
69
+ c.showPage() # Create a new page
70
 
71
+ # Add Screenshots (Top 5 Images) (New Page)
72
  c.drawString(72, y_position - 20, "Incident Screenshots:")
73
  y_position -= 40
74
  for screenshot in screenshots[:5]: # Limit to the top 5 images
75
  c.drawImage(screenshot, 72, y_position, width=150, height=100)
76
  y_position -= 120
77
+ c.showPage() # Create a new page
78
 
79
+ # Add Chart Image (New Page)
80
  c.drawString(72, y_position - 20, "Detection Trend Chart:")
81
  c.drawImage(chart_path, 72, y_position - 100, width=400, height=300)
82
+ c.showPage() # Create a new page
83
 
84
+ # Add Map Image (New Page)
85
  c.drawString(72, y_position - 140, "Issue Locations Map:")
86
  c.drawImage(map_path, 72, y_position - 240, width=400, height=300)
87