Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianfis committed Mar 24, 2024
1 parent e389e3d commit f8007eb
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions nms.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,61 +53,8 @@ def box_iou(box_i,boxes):

def non_max_suppresion_v8(prediction, conf_thres=0.25, iou_thres=0.45, classes=None, agnostic=False, multi_label=False,
labels=(), max_det=300):
# TODO: Test this for changed parameter number in yolov8!!! All that could be detected with last commit were persons!
#
# # Transpose and squeeze the output to match the expected shape
# # prediction = np.transpose(np.squeeze(prediction[0]))
# prediction = np.squeeze(prediction[0]) # eleminate batch id. only one batch can run un TPU anyway..., transpose is already done one step eralier
#
# # Get the number of rows in the outputs array
# rows = prediction.shape[0]
#
# # Lists to store the bounding boxes, scores, and class IDs of the detections
# boxes = []
# scores = []
# class_ids = []
#
# # Iterate over each row in the outputs array
# for i in range(rows):
# # Extract the class scores from the current row
# classes_scores = prediction[i][4:]
#
# # Find the maximum score among the class scores
# max_score = np.amax(classes_scores)
#
# # If the maximum score is above the confidence threshold
# if max_score >= conf_thres:
# # Get the class ID with the highest score
# class_id = np.argmax(classes_scores)
#
# # Add the class ID, score, and box coordinates to the respective lists
# class_ids.append(class_id)
# scores.append(max_score)
# boxes.append(xywh2xyxy(prediction[:, :4]))
#
# # Apply non-maximum suppression to filter out overlapping bounding boxes
# indices = nms(np.ndarray(boxes), np.ndarray(scores), iou_thres)
#
# if indices.shape[0] > max_det: # limit detections
# indices = indices[:max_det]
#
# if (time.time() - t) > time_limit:
# print(f'WARNING: NMS time limit {time_limit}s exceeded')
# break # time limit exceeded
#
#
# # Return the modified input image
# return input_image

nc = prediction.shape[2] - 4 # number of classes
# xc = prediction[..., 4] > conf_thres # candidates
# xc = []
# for xi, x in enumerate(prediction): # image index, image inference
# conf = np.amax(x[:, 4:], axis=1, keepdims=True)
# if np.any(conf > conf_thres):
# xc.append(True)
# else:
# xc.append(False)
xc = np.amax(prediction[..., 4:], axis=2) > conf_thres

# Checks
Expand Down

0 comments on commit f8007eb

Please sign in to comment.