NassimeBejaia commited on
Commit
6fceb8b
1 Parent(s): 6b8ee3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -73,7 +73,8 @@ def main():
73
  thresh_pil = process_image(selected_image_pil)
74
  st.image(thresh_pil, caption="Thresholded Image", use_column_width=True)
75
 
76
- processed_img_path = process_with_yolo(selected_image_pil)
 
77
 
78
  if processed_img_path:
79
  st.image(processed_img_path, caption="Processed with YOLO", use_column_width=True)
@@ -149,7 +150,24 @@ def process_image(selected_image):
149
 
150
 
151
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
 
153
 
154
 
155
 
 
73
  thresh_pil = process_image(selected_image_pil)
74
  st.image(thresh_pil, caption="Thresholded Image", use_column_width=True)
75
 
76
+ # processed_img_path = process_with_yolo(selected_image_pil)
77
+ processed_img_path = process_with_yolo(thresh_pil)
78
 
79
  if processed_img_path:
80
  st.image(processed_img_path, caption="Processed with YOLO", use_column_width=True)
 
150
 
151
 
152
 
153
+ def get_detected_boxes(txt_path, img_width, img_height):
154
+ with open(txt_path, 'r') as f:
155
+ lines = f.readlines()
156
+ boxes = []
157
+ for line in lines:
158
+ parts = list(map(float, line.strip().split()))
159
+ # Assuming the format is: class x_center y_center width height confidence
160
+ x_center, y_center, width, height = parts[1:5]
161
+
162
+ # Convert to pixel values
163
+ x_center *= img_width
164
+ y_center *= img_height
165
+ width *= img_width
166
+ height *= img_height
167
+
168
+ boxes.append([x_center, y_center, width, height])
169
 
170
+ return boxes
171
 
172
 
173