Yaswanth56 commited on
Commit
4dd541d
·
verified ·
1 Parent(s): d112f9e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py CHANGED
@@ -66,6 +66,33 @@ if device == "cpu": # Optional check
66
  model.float() # Ensure model is running on the CPU
67
  print(f"Model classes: {model.names}")
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  # Generate PDF report with Top 5 Images
70
  def generate_pdf_report(log_entries, detected_issues, chart_path, map_path, metrics, top_images):
71
  pdf = FPDF()
 
66
  model.float() # Ensure model is running on the CPU
67
  print(f"Model classes: {model.names}")
68
 
69
+ # Check Image Quality
70
+ def check_image_quality(frame: np.ndarray, input_resolution: int) -> bool:
71
+ """
72
+ Checks if the image quality (resolution) meets the required standard.
73
+
74
+ Args:
75
+ - frame (np.ndarray): The current frame being processed.
76
+ - input_resolution (int): The required resolution.
77
+
78
+ Returns:
79
+ - bool: True if the resolution is valid, False otherwise.
80
+ """
81
+ height, width, _ = frame.shape
82
+ frame_resolution = width * height
83
+
84
+ if frame_resolution < 12_000_000: # Minimum resolution of 12MP
85
+ log_entries.append(f"Frame {frame_count}: Resolution {width}x{height} ({frame_resolution / 1e6:.2f}MP) below 12MP, non-compliant")
86
+ logging.error(f"Frame {frame_count}: Resolution {width}x{height} ({frame_resolution / 1e6:.2f}MP) below 12MP, non-compliant")
87
+ return False
88
+
89
+ if frame_resolution < input_resolution:
90
+ log_entries.append(f"Frame {frame_count}: Output resolution {width}x{height} below input resolution")
91
+ logging.warning(f"Frame {frame_count}: Output resolution {width}x{height} below input resolution")
92
+ return False
93
+
94
+ return True
95
+
96
  # Generate PDF report with Top 5 Images
97
  def generate_pdf_report(log_entries, detected_issues, chart_path, map_path, metrics, top_images):
98
  pdf = FPDF()