コード例 #1
0
def evaluate(items, outs, config, trial=None):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat("beat")

    data, bpm_label, beat_label = items
    downbeattheta_out, delta_beattheta = outs

    # beat estimation
    downbeattheta_out = np.argmax(downbeattheta_out, axis=1) / 6000 * 2 * math.pi
    beat_metrics = eval_beat.batch(downbeattheta_out, beat_label)

    # # global bpm estimation
    # bpm_out = delta_beattheta * 3000 / math.pi
    # bpm_out = medfilt(bpm_out, kernel_size=[1, 21])
    # m, cnt = mode(np.round(bpm_out).astype(np.int64), axis=1)
    bpm_label = np.mean(bpm_label, axis=-1)
    m = calc_bpm_from_theta(downbeattheta_out, "beat")
    bpm_metrics = eval_bpm.global_(m, bpm_label)

    # local bpm estimation
    # bpm_metrics = eval_bpm.local(bpm_out, bpm_label)

    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret

    return ret
コード例 #2
0
def evaluate(items, outs, config):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")

    data, bpm_label, beat_label = items
    beattheta_out, delta_beattheta = outs

    # beat estimation
    beattheta_out = np.argmax(beattheta_out, axis=1) / 6000
    # theta = numpy_fft(beattheta_out * 2 * np.pi, 500)
    # theta /= (2 * np.pi)
    # activation = theta[:, :-1] - theta[:, 1:]
    # activation[activation <= 0] = 1e-6
    beat_metrics = eval_beat.batch(beattheta_out, beat_label)
    # beat_metrics = eval_beat.batch(activation, beat_label)

    # global bpm estimation
    bpm_out = delta_beattheta * 3000 / np.pi
    bpm_out = medfilt(bpm_out, kernel_size=[1, 21])
    m = calc_bpm_from_theta(beattheta_out * 2 * np.pi, "beat")
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(m, bpm_label)

    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #3
0
def evaluate(items, outs, config, data_type="test"):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")
    eval_downbeat = EvaluateDownbeat(estimated_type="activation",
                                     target_type="activation")

    data, bpm_label, beattheta_label, downbeattheta_label = items
    beattheta_out, downbeattheta_out, deltabeat_out, deltadownbeat_out = outs

    # beat estimation
    beattheta_out = np.argmax(beattheta_out, axis=1) / 6000
    downbeattheta_out = np.argmax(downbeattheta_out, axis=1) / 6000
    activation = beattheta_out[:, :-1] - beattheta_out[:, 1:]
    activation[activation <= 0.7] = 1e-6
    beat_metrics = eval_beat.batch(beattheta_out, beattheta_label)
    downbeat_met = eval_downbeat.batch(downbeattheta_out, downbeattheta_label)

    # global bpm estimation
    bpm_out = deltabeat_out * 3000 / np.pi
    bpm_out = medfilt(bpm_out, kernel_size=[1, 21])
    if data_type == "valid":
        m, cnt = mode(np.round(bpm_out).astype(np.int64), axis=1)
        m = m[:, 0]
    elif data_type == "test":
        m = calc_bpm_from_theta(beattheta_out * 2 * np.pi, "beat")
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(m, bpm_label)

    ret = {"beat": beat_metrics, "bpm": bpm_metrics, "downbeat": downbeat_met}
    return ret
コード例 #4
0
def evaluate(items, outs, config, trial=None):
    data, beat_label = items
    beattheta_out = outs
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")
    beattheta_out = np.argmax(beattheta_out, axis=1) / 6000
    beat_metrics = eval_beat.batch(beattheta_out, beat_label)
    ret = {"beat": beat_metrics}
    return ret
コード例 #5
0
def evaluate(items, outs, config, trial=None):
    data, bpm_label, beat_label = items
    beat_out, bpm_out = outs
    eval_beat = EvaluateBeat("downbeat")
    eval_bpm = EvaluateBpm()
    beat_metrics = eval_beat.batch(beat_out, beat_label)
    bpm_metrics = eval_bpm.local(bpm_out, bpm_label)
    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #6
0
def evaluate(items, outs, config, trial=None):
    data, bpm_label, beat_label = items
    bpm_out, beat_out = outs  # (b,300,T), (b,T)
    bpm_out = np.mean(bpm_out, axis=-1)
    bpm_out = np.argmax(bpm_out, axis=1)
    bpm_label = np.mean(bpm_label, axis=-1)
    eval_beat = EvaluateBeat("beat")
    eval_bpm = EvaluateBpm()
    beat_metrics = eval_beat.batch(beat_out, beat_label)
    bpm_metrics = eval_bpm.global_(bpm_out, bpm_label)
    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #7
0
def evaluate(items, outs, config, trial=None):
    data, bpm_label, beat_label = items
    bpm_out, beat_out = outs
    bpm_out = np.argmax(bpm_out, axis=1)
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")
    eval_bpm = EvaluateBpm()
    beat_metrics = eval_beat.batch(beat_out, beat_label)
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(bpm_out, bpm_label)
    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #8
0
def evaluate(items, outs, config, trial=None):
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")

    data, beat_label = items
    sintheta, costheta = outs
    theta = np.arctan2(sintheta, costheta)
    theta[theta < 0] += 2 * np.pi
    beat_metrics = eval_beat.batch(theta, beat_label)

    ret = {"beat": beat_metrics}
    return ret
コード例 #9
0
def evaluate(items, outs, config, trial=None):
    # eval_beat = EvaluateBeat(estimated_type="index", target_type="activation")
    eval_beat = EvaluateBeat(estimated_type="activation", target_type="activation")

    data, beat_label, bpm_label = items
    beattheta, f_softmax = outs
    # theta, idxs = numpy_fft(outs * 2 * np.pi, 100)
    # act = (outs[:, :-1] - outs[:, 1:]) / (2 * np.pi)
    # act[act <= 0] = 1e-5
    beat_metrics = eval_beat.batch(beattheta, beat_label)

    ret = {"beat": beat_metrics}
    return ret
コード例 #10
0
def evaluate(items, outs, config, trial=None):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat(estimated_type="activation", target_type="activation")

    data, bpm_label, beat_label = items
    beattheta_out, delta_beattheta = outs
    # beattheta_out, idxs = numpy_fft(beattheta_out * 2 * np.pi, 100)

    # beat estimation
    beat_metrics = eval_beat.batch(beattheta_out, beat_label)

    # global bpm estimation
    bpm_out = delta_beattheta * 3000 / np.pi
    bpm_out = medfilt(bpm_out, kernel_size=[1, 21])
    m = calc_bpm_from_theta(beattheta_out * 2 * np.pi, "beat")
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(m, bpm_label)

    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #11
0
def evaluate(items, outs, config, trial=None):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat("beat")

    data, bpm_label, beat_label = items
    beat_out, delta_beattheta = outs
    bpm_out = delta_beattheta * 3000 / math.pi
    bpm_out = medfilt(bpm_out, kernel_size=[1, 21])

    beat_metrics = eval_beat.batch(beat_out, beat_label)

    # global bpm estimation
    m, cnt = mode(np.round(bpm_out).astype(np.int64), axis=1)
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(m, bpm_label)

    # local bpm estimation
    # bpm_metrics = eval_bpm.local(bpm_out, bpm_label)

    ret = {"beat": beat_metrics, "bpm": bpm_metrics}
    return ret
コード例 #12
0
def evaluate(items, outs, config, trial=None):
    eval_bpm = EvaluateBpm()
    eval_beat = EvaluateBeat(estimated_type="activation",
                             target_type="activation")
    eval_downbeat = EvaluateDownbeat(estimated_type="activation",
                                     target_type="activation")

    data, bpm_label, beat_label, downbeat_label = items
    bpm_out, beat_out, downbeat_out = outs
    bpm_out = np.argmax(bpm_out, axis=1)

    beat_out = beat_out - downbeat_out
    beat_out[beat_out <= 0] = 1e-6

    beat_metrics = eval_beat.batch(beat_out, beat_label)
    downbeat_metrics = eval_downbeat.batch(downbeat_out, downbeat_label)
    bpm_label = np.mean(bpm_label, axis=-1)  # (batchsize,T) -> (batchsize)
    bpm_metrics = eval_bpm.global_(bpm_out, bpm_label)
    ret = {
        "beat": beat_metrics,
        "downbeat": downbeat_metrics,
        "bpm": bpm_metrics
    }
    return ret