Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

# Python egg
/madmom.egg-info/
/madmom_onnx.egg-info/

# Vim swap files
*.swp
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "madmom/models"]
path = madmom/models
url = https://github.com/CPJKU/madmom_models.git
url = https://github.com/alumkal/madmom_models.git
branch = master
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ prune tests
include CHANGES.rst
recursive-include madmom/ *.pyx
recursive-exclude madmom/ *.c
recursive-exclude madmom/ *.pkl
include madmom/models/chords/2016/chords_cnncrf.pkl
include madmom/models/chords/2016/chords_dccrf.pkl
include madmom/models/patterns/2013/ballroom_pattern_3_4.pkl
include madmom/models/patterns/2013/ballroom_pattern_4_4.pkl
63 changes: 54 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ It includes reference implementations for some music information retrieval
algorithms, please see the `References`_ section.


Changes from upstream madmom
============================

This is ``madmom-onnx``, a fork of `madmom <https://github.com/CPJKU/madmom>`_
that replaces the legacy pickle-based NumPy neural network inference with
`ONNX Runtime <https://onnxruntime.ai/>`_.

Key differences:

- All pre-trained neural network models are shipped as ``.onnx`` files instead
of ``.pkl``. Pickle-based model loading is removed.
- Neural network inference uses ONNX Runtime (``onnxruntime`` package) instead
of the custom NumPy-based forward pass.

Benchmark
---------

Measured on a 3m45s audio file, 10 runs each (mean +/- std):

======================== ================ ================ =========
Program madmom (pkl) madmom-onnx Speedup
======================== ================ ================ =========
CNNOnsetDetector 2.397 +/- 0.029s 1.442 +/- 0.046s 1.66x
BeatTracker 5.326 +/- 0.071s 4.298 +/- 0.087s 1.24x
TCNTempoDetector 5.081 +/- 0.321s 1.765 +/- 0.052s 2.88x
======================== ================ ================ =========

Generating ONNX model files
----------------------------

The ``.onnx`` model files are pre-generated and included in the repository. If
you need to regenerate them from the original ``.pkl`` files (e.g. after
modifying the converter), run::

python tools/convert_models_to_onnx.py --convert

This requires the ``onnx`` and ``scipy`` packages to be installed. The converter
reads each ``.pkl`` file, extracts the neural network layers, and writes an
equivalent ``.onnx`` graph to the same directory.


Documentation
=============

Expand Down Expand Up @@ -59,8 +100,8 @@ you choose, please make sure that all prerequisites are installed.
Prerequisites
-------------

To install the ``madmom`` package, you must have either Python 2.7 or Python
3.5 or newer and the following packages installed:
To install the ``madmom-onnx`` package, you must have either Python
3.9 or newer and the following packages installed:

- `numpy <http://www.numpy.org>`_
- `scipy <http://www.scipy.org>`_
Expand Down Expand Up @@ -93,16 +134,20 @@ please follow the steps in the next section.
The easiest way to install the package is via ``pip`` from the `PyPI (Python
Package Index) <https://pypi.python.org/pypi>`_::

pip install madmom
pip install madmom-onnx

This includes the latest stable release and will install all dependencies
automatically.

Alternatively, if you prefer the latest code that might be unstable::

This includes the latest code and trained models and will install all
dependencies automatically.
pip install git+https://github.com/CPJKU/madmom

You might need higher privileges (use su or sudo) to install the package, model
files and scripts globally. Alternatively you can install the package locally
(i.e. only for you) by adding the ``--user`` argument::

pip install --user madmom
pip install --user madmom-onnx

This will also install the executable programs to a common place (e.g.
``/usr/local/bin``), which should be in your ``$PATH`` already. If you
Expand Down Expand Up @@ -149,13 +194,13 @@ Upgrade a package

Simply upgrade the package via pip::

pip install --upgrade madmom [--user]
pip install --upgrade madmom-onnx [--user]

If some of the provided programs or models changed (please refer to the
CHANGELOG) you should first uninstall the package and then reinstall::

pip uninstall madmom
pip install madmom [--user]
pip uninstall madmom-onnx
pip install madmom-onnx [--user]

Upgrade from source
~~~~~~~~~~~~~~~~~~~
Expand Down
76 changes: 41 additions & 35 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../madmom'))
sys.path.insert(0, os.path.abspath("../madmom"))

# -- General configuration ------------------------------------------------

Expand All @@ -31,44 +31,44 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'numpydoc',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"numpydoc",
]

# see http://stackoverflow.com/q/12206334/562769
numpydoc_show_class_members = False

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'madmom'
copyright = u'2015, madmom development team'
author = u'madmom development team'
project = "madmom"
copyright = "2015, madmom development team"
author = "madmom development team"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = pkg_resources.get_distribution("madmom").version
version = pkg_resources.get_distribution("madmom-onnx").version
# The full version, including alpha/beta/rc tags.
release = version

Expand All @@ -87,7 +87,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all
# documents.
Expand All @@ -105,7 +105,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -119,9 +119,10 @@
# -- Options for HTML output ----------------------------------------------

# only import and set the theme if we're building docs locally
if os.environ.get('READTHEDOCS') != 'True':
if os.environ.get("READTHEDOCS") != "True":
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down Expand Up @@ -155,7 +156,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -218,20 +219,17 @@
# html_search_scorer = 'scorer.js'

# Output file base name for HTML help builder.
htmlhelp_basename = 'madmomdoc'
htmlhelp_basename = "madmomdoc"

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',

# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
Expand All @@ -240,8 +238,13 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'madmom.tex', u'madmom Documentation',
u'madmom development team', 'manual'),
(
master_doc,
"madmom.tex",
"madmom Documentation",
"madmom development team",
"manual",
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -269,10 +272,7 @@

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'madmom', u'madmom Documentation',
[author], 1)
]
man_pages = [(master_doc, "madmom", "madmom Documentation", [author], 1)]

# If true, show URL addresses after external links.
# man_show_urls = False
Expand All @@ -284,9 +284,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'madmom', u'madmom Documentation',
author, 'madmom', 'One line description of project.',
'Miscellaneous'),
(
master_doc,
"madmom",
"madmom Documentation",
author,
"madmom",
"One line description of project.",
"Miscellaneous",
),
]

# Documents to append as an appendix to all manuals.
Expand All @@ -302,4 +308,4 @@
# texinfo_no_detailmenu = False

# -- other options --------------------------------------------------------
autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"
14 changes: 7 additions & 7 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ all :ref:`prerequisites <install_prerequisites>` are installed.
Prerequisites
-------------

To install the ``madmom`` package, you must have either Python 2.7 or Python
To install the ``madmom-onnx`` package, you must have either Python 2.7 or Python
3.3 or newer and the following packages installed:

To install the ``madmom`` package, you must have either Python 2.7 or Python
To install the ``madmom-onnx`` package, you must have either Python 2.7 or Python
3.5 or newer and the following packages installed:

- `numpy <http://www.numpy.org>`_
Expand Down Expand Up @@ -51,7 +51,7 @@ please follow the steps in :ref:`the next section <install_from_source>`.
The easiest way to install the package is via ``pip`` from the `PyPI (Python
Package Index) <https://pypi.python.org/pypi>`_::

pip install madmom
pip install madmom-onnx

This includes the latest code and trained models and will install all
dependencies automatically.
Expand All @@ -60,7 +60,7 @@ You might need higher privileges (use su or sudo) to install the package, model
files and scripts globally. Alternatively you can install the package locally
(i.e. only for you) by adding the ``--user`` argument::

pip install --user madmom
pip install --user madmom-onnx

This will also install the executable programs to a common place (e.g.
``/usr/local/bin``), which should be in your ``$PATH`` already. If you
Expand Down Expand Up @@ -111,13 +111,13 @@ Upgrade a package

Simply upgrade the package via pip::

pip install --upgrade madmom [--user]
pip install --upgrade madmom-onnx [--user]

If some of the provided programs or models changed (please refer to the
CHANGELOG) you should first uninstall the package and then reinstall::

pip uninstall madmom
pip install madmom [--user]
pip uninstall madmom-onnx
pip install madmom-onnx [--user]

Upgrade from source
~~~~~~~~~~~~~~~~~~~
Expand Down
Loading