nagasurendra commited on
Commit
53065c4
·
verified ·
1 Parent(s): 73a391b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -14,6 +14,7 @@ from typing import List, Dict, Any, Optional
14
  from ultralytics import YOLO
15
  import piexif
16
  import zipfile
 
17
 
18
  os.environ["YOLO_CONFIG_DIR"] = "/tmp/Ultralytics"
19
  logging.basicConfig(filename="app.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
@@ -299,14 +300,21 @@ def generate_report(
299
  f"- DAMS Dashboard: `/project_xyz/dams/{datetime.now().strftime('%Y%m%d')}`",
300
  "",
301
  "## 14. Captured Images",
302
- "Below are the images from the captured frames directory showing detected issues:",
303
  ""
304
  ])
305
 
306
  for image_path in detected_issues:
307
  if os.path.exists(image_path):
308
  image_name = os.path.basename(image_path)
309
- report_content.append(f"![Captured image at {image_name}](captured_frames/{image_name})")
 
 
 
 
 
 
 
310
 
311
  try:
312
  with open(report_path, 'w') as f:
 
14
  from ultralytics import YOLO
15
  import piexif
16
  import zipfile
17
+ import base64
18
 
19
  os.environ["YOLO_CONFIG_DIR"] = "/tmp/Ultralytics"
20
  logging.basicConfig(filename="app.log", level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
 
300
  f"- DAMS Dashboard: `/project_xyz/dams/{datetime.now().strftime('%Y%m%d')}`",
301
  "",
302
  "## 14. Captured Images",
303
+ "Below are the embedded images from the captured frames directory showing detected issues:",
304
  ""
305
  ])
306
 
307
  for image_path in detected_issues:
308
  if os.path.exists(image_path):
309
  image_name = os.path.basename(image_path)
310
+ try:
311
+ with open(image_path, "rb") as image_file:
312
+ base64_string = base64.b64encode(image_file.read()).decode('utf-8')
313
+ report_content.append(f"![{image_name}](data:image/jpeg;base64,{base64_string})")
314
+ report_content.append(f"**Image: {image_name}**")
315
+ report_content.append("")
316
+ except Exception as e:
317
+ log_entries.append(f"Error: Failed to encode image {image_name} to base64: {str(e)}")
318
 
319
  try:
320
  with open(report_path, 'w') as f: