(self, samples)
return result
Do inference over the provided samples.
Do inference over the provided samples.
Do inference over the provided samples .
def infer(self, samples):
    """Do inference over the provided samples."""
    self._interpreter.set_tensor(
        self._interpreter.get_input_details()[0]['index'],
        samples)

    self._interpreter.invoke()
    predictions = [
        self._interpreter.get_tensor(self._output_index['frame_logits']),
        self._interpreter.get_tensor(self._output_index['onset_logits']),
        self._interpreter.get_tensor(self._output_index['offset_logits']),
        self._interpreter.get_tensor(self._output_index['velocity_values']),
    ]
    # Use axis 0 to stack but then shove the axis to the end so its
    # [time, midinote (0-88), {frame,onset, offset, velocity}]
    # The first 3 are logits, the last is simply the velocity
    result = np.transpose(np.concatenate(predictions, axis=0), [1, 2, 0])

    # TODO(fjord): Add onset filtering similar to our regular inference
    # setup.
    return result
def infer ( self , samples ) : self . _interpreter . set_tensor ( self . _interpreter . get_input_details ( ) [ 0 ] [ 'index' ] , samples ) self . _interpreter . invoke ( ) predictions = [ self . _interpreter . get_tensor ( self . _output_index [ 'frame_logits' ] ) , self . _interpreter . get_tensor ( self . _output_index [ 'onset_logits' ] ) , self . _interpreter . get_tensor ( self . _output_index [ 'offset_logits' ] ) , self . _interpreter . get_tensor ( self . _output_index [ 'velocity_values' ] ) , ] # Use axis 0 to stack but then shove the axis to the end so its # [time, midinote (0-88), {frame,onset, offset, velocity}] # The first 3 are logits, the last is simply the velocity result = np . transpose ( np . concatenate ( predictions , axis = 0 ) , [ 1 , 2 , 0 ] ) # TODO(fjord): Add onset filtering similar to our regular inference # setup. return result