Optical Music Recognition Datasets
Collection
All the available datasets for OMR.
β’
4 items
β’
Updated
SMB (Sheet Music Benchmark) is a dataset of printed Common Western Modern Notation scores developed at the University of Alicante at the Pattern Recognition and Artificial Intelligence Group.
Each page includes the corresponding **kern data for that specific page. Additionally, it provides detailed annotations for each region within the page.
SMB is publicly available at HuggingFace.
To download from HuggingFace:
pip install pillow datasets huggingface_hub[cli]huggingface-cli login and paste the HF access token. Check here for details.import math
from datasets import load_dataset
from PIL import ImageDraw
def draw_bounding_boxes(row):
"""
Draws bounding boxes on an image based on region data provided in the row.
Args:
row (dict): A row from the dataset.
Returns:
PIL.Image: An image with bounding boxes drawn.
"""
# Load the image
image = row["image"]
# Create a drawing context
draw = ImageDraw.Draw(image)
# Iterate through regions in the row
for index, region in enumerate(row["regions"]):
# Extract bounding box data
bbox = region["bbox"]
box_x = bbox["x"] / 100 * row["original_width"]
box_y = bbox["y"] / 100 * row["original_height"]
box_width = bbox["width"] / 100 * row["original_width"]
box_height = bbox["height"] / 100 * row["original_height"]
rotation = bbox["rotation"]
# Convert rotation to radians
rotation_rad = math.radians(rotation)
# Calculate the corners relative to the top-left corner (anchor point)
corners = [
(0, 0), # Top-left
(box_width, 0), # Top-right
(box_width, box_height), # Bottom-right
(0, box_height), # Bottom-left
]
# Apply rotation around the top-left corner
rotated_corners = []
for x, y in corners:
rotated_x = box_x + x * math.cos(rotation_rad) - y * math.sin(rotation_rad)
rotated_y = box_y + x * math.sin(rotation_rad) + y * math.cos(rotation_rad)
rotated_corners.append((rotated_x, rotated_y))
# Draw the rotated rectangle
draw.polygon(rotated_corners, outline="red", width=3)
# Show region data
print(f"\nRegion {index}:"
f"\nRotation (degrees): {rotation}"
f"\nkern: {region['kern']}")
return image
if __name__ == "__main__":
# Load dataset from Hugging Face
ds = load_dataset("PRAIG/SMB")
# Select a subset of the dataset
ds = ds["test"]
# Iterate through rows in the dataset
for row in ds:
# Draw bounding boxes on the image
image = draw_bounding_boxes(row)
# Show the image and wait for user to close it
image.show()
input("Close the image window and press Enter to continue...")
If you use our work, please cite us:
@preprint{,
author = {,
title = {},
year = {}
}