Skip to main content

Smude - Sheet Music Dewarping

Smude is a library dedicated to binarization and dewarping/rectification of sheet music images taken with smartphones:

Requirements

  • Python 3.10+
  • ~348 MB disk space for the Deep Learning model (downloaded on first run)

Installation

pip install smude

Using uv

uv is a fast Python package manager:

uv pip install smude

From source

git clone https://github.com/sonovice/smude.git
cd smude
pip install .

Usage

Command Line

Installing the package adds a command-line interface called smude:

smude input.jpg -o output.png

Options:

usage: smude [-h] [-o OUTFILE] [--no-binarization] [--use-gpu] infile

Dewarp and binarize sheet music images.

positional arguments:
  infile                Specify the input image

options:
  -h, --help            show this help message and exit
  -o OUTFILE, --outfile OUTFILE
                        Specify the output image (default: result.png)
  --no-binarization     Deactivate binarization
  --use-gpu             Use GPU for inference

Python Library

from skimage.io import imread, imsave
from smude import Smude

image = imread("images/input_fullsize.jpg")
smude = Smude(use_gpu=False, binarize_output=True)
result = smude.process(image)
imsave("result.png", result)

Note: Smude will download a ~348 MB Deep Learning model on the first run.

How It Works

Rectification of sheet music pages is divided into several steps:

  1. ROI Extraction - Extract the sheet music page from the smartphone image
  2. Adaptive Binarization - Convert to binary image using Sauvola algorithm
  3. U-Net Segmentation - Pixelwise segmentation into "upper staff line", "lower staff line", and "bar line" classes
  4. Vanishing Point Estimation - Estimate the perspective vanishing point
  5. Spline Interpolation - Fit splines to detected staff lines
  6. Dewarping - Rectify the curved page geometry

The Deep Learning model was trained on thousands of public domain scores from musescore.com, augmented and rendered with Verovio, and artificially warped using code from NVlabs/ocrodeg.

The dewarping algorithm is based on:

Meng, G. et al. (2012): Metric Rectification of Curved Document Images. IEEE Transactions on Pattern Analysis and Machine Intelligence, 34(4), p. 707-722. DOI: 10.1109/TPAMI.2011.151

Tips for Best Results

  • Full page coverage - Include the entire page plus some extra margins
  • Even lighting - Ensure the sheet music is evenly lit without shadows
  • Sharp focus - Blurry or defocused images will likely fail
  • Book curvature - Works best with pages that have a cylindrical surface curve (typical for bound books)

License

This repository is under the "Commons Clause" License Condition v1.0 on top of GNU AGPLv3.

Metadata

Release files for smude 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smude 0.2.1
File Size Uploaded Provenance Actions
smude-0.2.1.tar.gz 333.6 kB Without provenance Details for smude-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smude 0.2.1
File Interpreter ABI Platform Actions
smude-0.2.1-py3-none-any.whl Python 3 none any Details for smude-0.2.1-py3-none-any.whl

Total release size: 357.5 kB

Release files / smude-0.2.1.tar.gz

Download URL smude-0.2.1.tar.gz
Size 333.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4631e2fd914d971964f8ee421c3e61b9a8c0c70785cc4120baef7a8d9b4404dd
BLAKE2b-256 checksum
How to use checksums
0e25771b38f25408943887f01d551c86384629c215bd02334782b3aaa4404c3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Release files / smude-0.2.1-py3-none-any.whl

Download URL smude-0.2.1-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1f5f50674f7a0a1fb59e485719f662fed0a4e87eb3c04fb07380b86cb38e7bd
BLAKE2b-256 checksum
How to use checksums
8db383764c08ad43050eea91da197051463c8c3592f2bd86e875d7f06b6fd53d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.2

Security for smude 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page