targets.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:chordrec 作者: fdlm 项目源码 文件源码
def _targets_to_annotations(self, targets):
        natural = zip([0, 2, 3, 5, 7, 8, 10], string.uppercase[:7])
        sharp = map(lambda v: ((v[0] + 1) % 12, v[1] + '#'), natural)

        semitone_to_label = dict(sharp + natural + [(12, 'N')])
        spf = 1. / self.fps
        labels = [(i * spf, semitone_to_label[p])
                  for i, p in enumerate(targets)]

        # join same consequtive predictions
        prev_label = (None, None)
        uniq_labels = []

        for label in labels:
            if label[1] != prev_label[1]:
                uniq_labels.append(label)
                prev_label = label

        # end time of last label is one frame duration after
        # the last prediction time
        start_times, chord_labels = zip(*uniq_labels)
        end_times = start_times[1:] + (labels[-1][0] + spf,)

        return zip(start_times, end_times, chord_labels)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号