def construct_frame_level_lfb()

in tools/lfb_loader.py [0:0]


def construct_frame_level_lfb(all_features, all_metadata):
    """Construct an frame-level LFB (e.g., for EPIC-Kitchens and Chrades)."""
    lfb = {}

    global_idx = 0
    for iter_features in all_features:
        for gpu_features in iter_features:
            batch_size = gpu_features.shape[0]

            for i in range(batch_size):
                if global_idx >= len(all_metadata):
                    break
                if cfg.DATASET == 'epic':
                    _, video_id, frame_id, _, _, _ = all_metadata[global_idx]
                elif cfg.DATASET == 'charades':
                    video_id, frame_id = all_metadata[global_idx]
                global_idx += 1

                if video_id not in lfb:
                    lfb[video_id] = {}

                lfb[video_id][frame_id] = np.squeeze(gpu_features[i])

    logger.info('LFB constructed')
    logger.info('\t%d frames in %d videos (%.03f frames / video).' % (
        global_idx, len(lfb), float(global_idx) / len(lfb)))

    return lfb