Skip to content

Commit

Permalink
refactored the ml.rnn to ml.nn and added tests; updated the models su…
Browse files Browse the repository at this point in the history
…bmodule
  • Loading branch information
Sebastian Böck committed Mar 9, 2016
1 parent 4ef285d commit 83d5ff8
Show file tree
Hide file tree
Showing 20 changed files with 847 additions and 851 deletions.
8 changes: 4 additions & 4 deletions bin/BeatDetector
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import BeatDetectionProcessor
from madmom.features.tempo import TempoEstimationProcessor
Expand Down Expand Up @@ -95,7 +95,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -120,8 +120,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
8 changes: 4 additions & 4 deletions bin/BeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import BeatTrackingProcessor
from madmom.features.tempo import TempoEstimationProcessor
Expand Down Expand Up @@ -94,7 +94,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -119,8 +119,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
8 changes: 4 additions & 4 deletions bin/CRFBeatDetector
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import CRFBeatDetectionProcessor
from madmom.features.tempo import TempoEstimationProcessor
Expand Down Expand Up @@ -97,7 +97,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -122,8 +122,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
8 changes: 4 additions & 4 deletions bin/DBNBeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.beats import DBNBeatTrackingProcessor

Expand Down Expand Up @@ -95,7 +95,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -120,8 +120,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
8 changes: 4 additions & 4 deletions bin/MMBeatTracker
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor
from madmom.ml.nn import NeuralNetwork
from madmom.features import ActivationsProcessor
from madmom.features.beats import (DBNBeatTrackingProcessor,
MultiModelSelectionProcessor)
Expand Down Expand Up @@ -102,7 +102,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -127,8 +127,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and select the best predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
if args.nn_ref_files is None:
# set the nn_ref_files the same as the nn_files, i.e. average them
args.nn_ref_files = args.nn_files
Expand Down
8 changes: 4 additions & 4 deletions bin/OnsetDetector
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.onsets import PeakPickingProcessor

Expand Down Expand Up @@ -85,7 +85,7 @@ def main():
args.diff_ratio = 0.25
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/onsets/2013/onsets_brnn_[1-8].npz" %
args.nn_files = glob.glob("%s/onsets/2013/onsets_brnn_[1-8].pkl" %
MODELS_PATH)
args.pre_max = 1. / args.fps
args.post_max = 1. / args.fps
Expand All @@ -112,8 +112,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
8 changes: 4 additions & 4 deletions bin/OnsetDetectorLL
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.onsets import PeakPickingProcessor

Expand Down Expand Up @@ -96,7 +96,7 @@ def main():
args.diff_ratio = 0.25
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/onsets/2013/onsets_rnn_[1-8].npz" %
args.nn_files = glob.glob("%s/onsets/2013/onsets_rnn_[1-8].pkl" %
MODELS_PATH)
args.pre_max = 1. / args.fps
args.post_max = 0
Expand Down Expand Up @@ -124,8 +124,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
15 changes: 6 additions & 9 deletions bin/PianoTranscriptor
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork
from madmom.features import ActivationsProcessor
from madmom.features.onsets import PeakPickingProcessor
from madmom.features.notes import (write_midi, write_notes, write_mirex_format,
note_reshaper)
from madmom.features.notes import write_midi, write_notes, write_mirex_format


def main():
Expand Down Expand Up @@ -95,7 +94,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/notes/2013/notes_brnn.npz" % MODELS_PATH)
args.nn_file = "%s/notes/2013/notes_brnn.pkl" % MODELS_PATH
args.pre_max = 1. / args.fps
args.post_max = 1. / args.fps

Expand Down Expand Up @@ -125,12 +124,10 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
avg = average_predictions
reshape = note_reshaper
# process everything with a RNN
rnn = NeuralNetwork.load(args.nn_file)
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg, reshape]
in_processor = [sig, multi, stack, rnn]

# output processor
if args.save:
Expand Down
11 changes: 6 additions & 5 deletions bin/SuperFluxNN
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import glob
import argparse

from madmom import MODELS_PATH
from madmom.processors import IOProcessor, io_arguments
from madmom.processors import ParallelProcessor, IOProcessor, io_arguments
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.filters import FilterbankProcessor
from madmom.audio.spectrogram import (LogarithmicSpectrogramProcessor,
SpectrogramDifferenceProcessor,
SuperFluxProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.onsets import SpectralOnsetProcessor, PeakPickingProcessor

Expand Down Expand Up @@ -82,7 +82,7 @@ def main():
args.fps = 100
args.online = False
args.onset_method = 'superflux'
args.nn_files = glob.glob("%s/onsets/2014/onsets_brnn_pp_[1-8].npz" %
args.nn_files = glob.glob("%s/onsets/2014/onsets_brnn_pp_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -106,9 +106,10 @@ def main():
# save the Onset activations to file
out_processor = ActivationsProcessor(mode='w', **vars(args))
else:
# perform RNN processing, averaging and peak-picking
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# perform peak picking, i.e. select the local maxima
pp = PeakPickingProcessor(**vars(args))
from madmom.utils import write_events as writer
# sequentially process them
Expand Down
8 changes: 4 additions & 4 deletions bin/TempoDetector
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from madmom.processors import (SequentialProcessor, ParallelProcessor,
from madmom.audio.signal import SignalProcessor, FramedSignalProcessor
from madmom.audio.spectrogram import (LogarithmicFilteredSpectrogramProcessor,
SpectrogramDifferenceProcessor)
from madmom.ml.rnn import RNNProcessor, average_predictions
from madmom.ml.nn import NeuralNetwork, average_predictions
from madmom.features import ActivationsProcessor
from madmom.features.tempo import TempoEstimationProcessor, write_tempo

Expand Down Expand Up @@ -90,7 +90,7 @@ def main():
args.diff_ratio = 0.5
args.positive_diffs = True
args.stack_diffs = np.hstack
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].npz" %
args.nn_files = glob.glob("%s/beats/2013/beats_blstm_[1-8].pkl" %
MODELS_PATH)

# print arguments
Expand All @@ -115,8 +115,8 @@ def main():
# wrap everything in a ParallelProcessor and stack the features
multi = ParallelProcessor(multi)
stack = np.hstack
# process everything with an RNN and average the predictions
rnn = RNNProcessor(**vars(args))
# process everything with multiple RNNs and average the predictions
rnn = ParallelProcessor([NeuralNetwork.load(f) for f in args.nn_files])
avg = average_predictions
# sequentially process everything
in_processor = [sig, multi, stack, rnn, avg]
Expand Down
2 changes: 1 addition & 1 deletion madmom/ml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from __future__ import absolute_import, division, print_function

# import the submodules
from . import rnn, hmm, gmm
from . import nn, hmm, gmm
Loading

0 comments on commit 83d5ff8

Please sign in to comment.