def _prepare_iou_dict(self): pbar = tqdm(total=len(self.video_list)) for cnt, video in enumerate(self.video_list): # 对于每一个video pbar.update(1) fg = video.get_fg(self.fg_iou_thresh, self.gt_as_fg) # 前景 incomp, bg = video.get_negatives( self.incomplete_iou_thresh, self.bg_iou_thresh, self.bg_coverage_thresh, self.incomplete_overlap_thresh) #背景区域 self.prop_dict[video.id] = [fg, incomp, bg] # 为每个video选择不同的前景 背景 和不完整片段 video_pool = fg + incomp + bg # calculate act iou matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) iou_array, overlap_array = segment_tiou( prop_array, prop_array) # 计算所有proposal之间的IOU and overlap 便于邻接矩阵 [N, N] self.act_iou_dict[video.id] = iou_array # calculate act distance matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) distance_array = segment_distance( prop_array, prop_array) # 计算proposal之间的距离 [N, N] self.act_dis_dict[video.id] = distance_array pbar.close()
def _prepare_iou_dict2(video_list, fg_iou_thresh, gt_as_fg, incomplete_iou_thresh, bg_iou_thresh, bg_coverage_thresh, incomplete_overlap_thresh): prop_dict = {} act_iou_dict = {} act_dis_dict = {} pbar = tqdm(total=len(video_list)) for cnt, video in enumerate(video_list): pbar.update(1) fg = video.get_fg(fg_iou_thresh, gt_as_fg) incomp, bg = video.get_negatives(incomplete_iou_thresh, bg_iou_thresh, bg_coverage_thresh, incomplete_overlap_thresh) prop_dict[video.id] = [fg, incomp, bg] video_pool = fg + incomp + bg # calculate act iou matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) iou_array, overlap_array = segment_tiou(prop_array, prop_array) act_iou_dict[video.id] = iou_array # calculate act distance matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) distance_array = segment_distance(prop_array, prop_array) act_dis_dict[video.id] = distance_array pbar.close() return prop_dict, act_iou_dict, act_dis_dict
def _prepare_test_iou_dict(self): pbar = tqdm(total=len(self.video_list)) for cnt, video in enumerate(self.video_list): pbar.update(1) video_pool = video.proposals # calculate act iou matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) iou_array, overlap_array = segment_tiou(prop_array, prop_array) self.act_iou_dict[video.id] = iou_array # calculate act distance matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) distance_array = segment_distance(prop_array, prop_array) self.act_dis_dict[video.id] = distance_array pbar.close()
def _prepare_iou_dict(self): pbar = tqdm(total=len(self.video_list)) for cnt, video in enumerate(self.video_list): pbar.update(1) fg = video.get_fg(self.fg_iou_thresh, self.gt_as_fg) incomp, bg = video.get_negatives(self.incomplete_iou_thresh, self.bg_iou_thresh, self.bg_coverage_thresh, self.incomplete_overlap_thresh) self.prop_dict[video.id] = [fg, incomp, bg] video_pool = fg + incomp + bg # calculate act iou matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) iou_array, overlap_array = segment_tiou(prop_array, prop_array) self.act_iou_dict[video.id] = torch.from_numpy(iou_array).cuda().float() # calculate act distance matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) distance_array = segment_distance(prop_array, prop_array) self.act_dis_dict[video.id] = torch.from_numpy(distance_array).cuda().float() pbar.close()
def _prepare_iou_dict(self): pbar = tqdm(total=len(self.video_list)) for cnt, video in enumerate(self.video_list): pbar.update(1) fg = video.get_fg(self.fg_iou_thresh, self.gt_as_fg) incomp, bg = video.get_negatives(self.incomplete_iou_thresh, self.bg_iou_thresh, self.bg_coverage_thresh, self.incomplete_overlap_thresh) self.prop_dict[video.id] = [fg, incomp, bg] video_pool = fg + incomp + bg # 将所有的提议全加到video_pool中 # calculate act iou matrix prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) # 计算所有提议间的IOU和重叠大小(intersection) iou_array, overlap_array = segment_tiou(prop_array, prop_array) self.act_iou_dict[video.id] = iou_array # calculate act distance matrix # distance = |c1-c2| / Union(c1,c2) prop_array = np.array([[prop.start_frame, prop.end_frame] for prop in video_pool]) distance_array = segment_distance(prop_array, prop_array) self.act_dis_dict[video.id] = distance_array pbar.close()