(frame_probs,
                     onset_probs,
                     frame_predictions,
                     onset_predictions,
                     offset_predictions,
                     velocity_values,
                     min_pitch,
                     hparams,
                     onsets_only=False)
return sequence_prediction
Predict sequence given model output.
Predict sequence given model output.
Predict sequence given model output .
def predict_sequence(frame_probs,
                     onset_probs,
                     frame_predictions,
                     onset_predictions,
                     offset_predictions,
                     velocity_values,
                     min_pitch,
                     hparams,
                     onsets_only=False):
  """Predict sequence given model output."""
  if not hparams.predict_onset_threshold:
    onset_predictions = None
  if not hparams.predict_offset_threshold:
    offset_predictions = None

  if onsets_only:
    if onset_predictions is None:
      raise ValueError(
          'Cannot do onset only prediction if onsets are not defined.')
    sequence_prediction = sequences_lib.pianoroll_onsets_to_note_sequence(
        onsets=onset_predictions,
        frames_per_second=data.hparams_frames_per_second(hparams),
        note_duration_seconds=0.05,
        min_midi_pitch=min_pitch,
        velocity_values=velocity_values,
        velocity_scale=hparams.velocity_scale,
        velocity_bias=hparams.velocity_bias)
  else:
    if hparams.viterbi_decoding:
      pianoroll = probs_to_pianoroll_viterbi(
          frame_probs, onset_probs, alpha=hparams.viterbi_alpha)
      onsets = np.concatenate([
          pianoroll[:1, :], pianoroll[1:, :] & ~pianoroll[:-1, :]
      ], axis=0)
      sequence_prediction = sequences_lib.pianoroll_to_note_sequence(
          frames=pianoroll,
          frames_per_second=data.hparams_frames_per_second(hparams),
          min_duration_ms=0,
          min_midi_pitch=min_pitch,
          onset_predictions=onsets,
          velocity_values=velocity_values,
          velocity_scale=hparams.velocity_scale,
          velocity_bias=hparams.velocity_bias)
    else:
      sequence_prediction = sequences_lib.pianoroll_to_note_sequence(
          frames=frame_predictions,
          frames_per_second=data.hparams_frames_per_second(hparams),
          min_duration_ms=0,
          min_midi_pitch=min_pitch,
          onset_predictions=onset_predictions,
          offset_predictions=offset_predictions,
          velocity_values=velocity_values,
          velocity_scale=hparams.velocity_scale,
          velocity_bias=hparams.velocity_bias)

  return sequence_prediction
def predict_sequence ( frame_probs , onset_probs , frame_predictions , onset_predictions , offset_predictions , velocity_values , min_pitch , hparams , onsets_only = False ) : if not hparams . predict_onset_threshold : onset_predictions = None if not hparams . predict_offset_threshold : offset_predictions = None if onsets_only : if onset_predictions is None : raise ValueError ( 'Cannot do onset only prediction if onsets are not defined.' ) sequence_prediction = sequences_lib . pianoroll_onsets_to_note_sequence ( onsets = onset_predictions , frames_per_second = data . hparams_frames_per_second ( hparams ) , note_duration_seconds = 0.05 , min_midi_pitch = min_pitch , velocity_values = velocity_values , velocity_scale = hparams . velocity_scale , velocity_bias = hparams . velocity_bias ) else : if hparams . viterbi_decoding : pianoroll = probs_to_pianoroll_viterbi ( frame_probs , onset_probs , alpha = hparams . viterbi_alpha ) onsets = np . concatenate ( [ pianoroll [ : 1 , : ] , pianoroll [ 1 : , : ] & ~ pianoroll [ : - 1 , : ] ] , axis = 0 ) sequence_prediction = sequences_lib . pianoroll_to_note_sequence ( frames = pianoroll , frames_per_second = data . hparams_frames_per_second ( hparams ) , min_duration_ms = 0 , min_midi_pitch = min_pitch , onset_predictions = onsets , velocity_values = velocity_values , velocity_scale = hparams . velocity_scale , velocity_bias = hparams . velocity_bias ) else : sequence_prediction = sequences_lib . pianoroll_to_note_sequence ( frames = frame_predictions , frames_per_second = data . hparams_frames_per_second ( hparams ) , min_duration_ms = 0 , min_midi_pitch = min_pitch , onset_predictions = onset_predictions , offset_predictions = offset_predictions , velocity_values = velocity_values , velocity_scale = hparams . velocity_scale , velocity_bias = hparams . velocity_bias ) return sequence_prediction