Пример #1
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
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
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
Пример #4
0
def evaluate(items, outs, config, trial=None):
    data, bpm_label = items
    bpm_out = np.argmax(outs, axis=1)
    bpm_label = np.mean(bpm_label, axis=-1)
    eval_bpm = EvaluateBpm()
    bpm_metrics = eval_bpm.global_(bpm_out, bpm_label)
    ret = {"bpm": bpm_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 = items
    bpm_out = np.argmax(outs, axis=1)
    bpm_out = medfilt(bpm_out, kernel_size=[1, 21])
    m, cnt = mode(np.round(bpm_out).astype(np.int64), axis=1)
    eval_bpm = EvaluateBpm()
    bpm_label = np.mean(bpm_label, axis=-1)
    bpm_metrics = eval_bpm.global_(m[:, 0], bpm_label)
    ret = {"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  # (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
Пример #8
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
Пример #9
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
Пример #10
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
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
Пример #12
0
def evaluate(items, outs, config, optimize=False):
    beat, bpm = items
    eval_bpm = EvaluateBpm()
    bpm_metrics = eval_bpm.local(outs, bpm)
    ret = {"bpm": bpm_metrics}
    return ret