def wrapper_nms(proposal_df, overlap=0.65):
"""Apply non-max-suppresion to a video batch.
"""
vds_unique = pd.unique(proposal_df['video-name'])
new_proposal_df = []
for i, v in enumerate(vds_unique):
idx = proposal_df['video-name'] == v
p = proposal_df.loc[idx, ['video-name', 'f-init', 'f-end',
'score', 'video-frames']]
n_frames = np.int(p['video-frames'].mean())
loc = np.stack((p['f-init'], p['f-end']), axis=-1)
loc, score = nms_detections(loc, np.array(p['score']), overlap)
n_proposals = score.shape[0]
n_frames = np.repeat(p['video-frames'].mean(), n_proposals).astype(int)
this_df = pd.DataFrame({'video-name': np.repeat(v, n_proposals),
'f-init': loc[:, 0], 'f-end': loc[:, 1],
'score': score,
'video-frames': n_frames})
new_proposal_df.append(this_df)
return pd.concat(new_proposal_df, axis=0)
评论列表
文章目录