def set_responsibilities(anchor_frames, iou_thresh=0.6):
"""
Changes the IOU values for the anchor frames to binary values
anchor_frames: list of frames where each frame contains all features for a specific anchor
iou_thresh: threshold to decide which anchor is responsible
"""
# set box with maximum IOU to 1
anchor_frames = [frame.copy() for frame in anchor_frames]
# find maximum IOU value over all frames
helper_array = np.array([frame[frame.columns[0]] for frame in anchor_frames]).T
max_indices = np.argmax(helper_array, axis=1)
data_idx = np.arange(len(max_indices))
for obj_idx, frame_idx in zip(data_idx, max_indices):
temp_frame = anchor_frames[frame_idx]
temp_frame.loc[obj_idx, temp_frame.columns[0]] = 1
# applying the iou threshold on a copy of the dataframes
for frame in anchor_frames:
frame[frame.columns[0]] = np.digitize(frame[frame.columns[0]], [iou_thresh])
return anchor_frames
评论列表
文章目录