PDF2Muse is a modern Python tool that converts PDF files of sheet music into MusicXML πΌ and MuseScore (.mscx) files using optical music recognition (OMR). It leverages the power of the oemer library to transcribe music from PDFs.
- Easy to use: Simple command-line interface and web UI
- High quality: Uses state-of-the-art optical music recognition
- Flexible output: Generates both MusicXML and MuseScore formats
- Modern architecture: Built with modern Python best practices
- Beautiful output: Rich terminal output with progress indicators
This project would not have been possible without the excellent work done by the oemer project. We extend our sincere gratitude to the oemer team for creating such a powerful and versatile optical music recognition library.
- Python 3.9 or higher π
- Poppler (for PDF to image conversion)
pip install -e .pip install -e ".[dev]"The package will automatically install all required dependencies including:
- oemer (optical music recognition)
- pdf2image (PDF conversion)
- typer (CLI framework)
- gradio (web interface)
- rich (beautiful terminal output)
Poppler is required for PDF to image conversion:
Windows:
# Using Chocolatey
choco install poppler
# Or download from: https://github.com/oschwartz10612/poppler-windows/releases/macOS:
brew install popplerLinux (Ubuntu/Debian):
sudo apt-get install poppler-utilsConvert a PDF file:
pdf2muse convert sheet_music.pdfSpecify output directory:
pdf2muse convert sheet_music.pdf --output ./my_outputDisable deskewing:
pdf2muse convert sheet_music.pdf --no-deskewUse TensorFlow instead of ONNX:
pdf2muse convert sheet_music.pdf --use-tfEnable verbose logging:
pdf2muse convert sheet_music.pdf --verboseShow help:
pdf2muse --help
pdf2muse convert --helpLaunch the Gradio web UI:
pdf2muse uiWith custom port:
pdf2muse ui --port 8080Create a public shareable link:
pdf2muse ui --sharePre-download the oemer model checkpoints:
pdf2muse download-modelsForce re-download:
pdf2muse download-models --forcePDF2Muse/
βββ src/
β βββ pdf2muse/
β βββ __init__.py # Package initialization
β βββ cli.py # Typer CLI entry point
β βββ core.py # Main processing pipeline
β βββ oemer_utils.py # Oemer wrapper utilities
β βββ musicxml.py # MusicXML manipulation
β βββ ui.py # Gradio web interface
βββ pyproject.toml # Project metadata & dependencies
βββ README.md # This file
βββ .gitignore
pytestblack src/ruff check src/- PDF to Images: Converts each page of the PDF to a high-resolution PNG image
- OMR Processing: Runs oemer on each image to extract musical notation
- MusicXML Generation: Combines the recognized music into MusicXML format
- MuseScore Conversion: Converts the MusicXML to MuseScore's .mscx format
For optimal recognition quality:
- Use high-resolution scans (300 DPI or higher)
- Ensure clear, uncluttered sheet music
- Use standard Western music notation
- Avoid handwritten scores (printed music works best)
Import Error: No module named 'pdf2muse'
- Make sure you installed the package:
pip install -e .
Command not found: pdf2muse
- Ensure your Python scripts directory is in your PATH
- Try running:
python -m pdf2muse.cliinstead
Poppler error during conversion
- Install Poppler (see Installation section above)
- On Windows, add Poppler's bin directory to your PATH
No MusicXML files generated
- Check that your PDF contains clear sheet music
- Try enabling verbose mode:
pdf2muse convert file.pdf --verbose - Ensure oemer checkpoints are downloaded:
pdf2muse download-models
MIT License - see LICENSE file for details.
- Homepage: https://github.com/thedivergentai/PDF2Muse
- Issues: https://github.com/thedivergentai/PDF2Muse/issues
- oemer Library: https://github.com/BreezeWhite/oemer