BhumikaMak commited on
Commit
00c75f1
·
verified ·
1 Parent(s): 04535ac

debug: dff_nmf removed prob, boxes

Browse files
Files changed (1) hide show
  1. yolov8.py +15 -15
yolov8.py CHANGED
@@ -183,30 +183,30 @@ def dff_nmf(image, target_lyr, n_components):
183
  detections = results[0] # The first element should contain the detection data
184
 
185
  # Access detection results
186
- boxes = detections.boxes.xyxy.cpu().numpy() # Bounding box coordinates (xyxy)
187
- probs = detections.probs.cpu().numpy() # Confidence scores (probabilities)
188
- classes = detections.classes.cpu().numpy() # Class IDs
189
 
190
  # Filter detections with confidence score > threshold (e.g., 0.5)
191
- high_conf_indices = probs > 0.5
192
- high_conf_boxes = boxes[high_conf_indices]
193
- high_conf_classes = classes[high_conf_indices]
194
- high_conf_probs = probs[high_conf_indices]
195
 
196
  # Example visualization and output processing
197
  fig, ax = plt.subplots(1, figsize=(8, 8))
198
  ax.axis("off")
199
  ax.imshow(rgb_img_float)
200
 
201
- for box, cls, prob in zip(high_conf_boxes, high_conf_classes, high_conf_probs):
202
- x1, y1, x2, y2 = box
203
- rect = patches.Rectangle((x1, y1), x2 - x1, y2 - y1,
204
- linewidth=2, edgecolor='r', facecolor='none')
205
- ax.add_patch(rect)
206
- ax.text(x1, y1, f"Class {cls}, Prob {prob:.2f}", color='r', fontsize=12, verticalalignment='top')
207
 
208
- plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
209
- fig.canvas.draw()
210
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
211
  image_resized = cv2.resize(image_array, (640, 640))
212
  rgba_channels = cv2.split(image_resized)
 
183
  detections = results[0] # The first element should contain the detection data
184
 
185
  # Access detection results
186
+ #boxes = detections.boxes.xyxy.cpu().numpy() # Bounding box coordinates (xyxy)
187
+ #probs = detections.probs.cpu().numpy() # Confidence scores (probabilities)
188
+ #classes = detections.classes.cpu().numpy() # Class IDs
189
 
190
  # Filter detections with confidence score > threshold (e.g., 0.5)
191
+ #high_conf_indices = probs > 0.5
192
+ #high_conf_boxes = boxes[high_conf_indices]
193
+ #high_conf_classes = classes[high_conf_indices]
194
+ #high_conf_probs = probs[high_conf_indices]
195
 
196
  # Example visualization and output processing
197
  fig, ax = plt.subplots(1, figsize=(8, 8))
198
  ax.axis("off")
199
  ax.imshow(rgb_img_float)
200
 
201
+ #for box, cls, prob in zip(high_conf_boxes, high_conf_classes, high_conf_probs):
202
+ # x1, y1, x2, y2 = box
203
+ # rect = patches.Rectangle((x1, y1), x2 - x1, y2 - y1,
204
+ # linewidth=2, edgecolor='r', facecolor='none')
205
+ # ax.add_patch(rect)
206
+ # ax.text(x1, y1, f"Class {cls}, Prob {prob:.2f}", color='r', fontsize=12, verticalalignment='top')
207
 
208
+ # plt.subplots_adjust(left=0, right=1, top=1, bottom=0)
209
+ #fig.canvas.draw()
210
  image_array = np.array(fig.canvas.renderer.buffer_rgba())
211
  image_resized = cv2.resize(image_array, (640, 640))
212
  rgba_channels = cv2.split(image_resized)