|
--- |
|
license: cc-by-nc-4.0 |
|
tags: |
|
- music |
|
- documents |
|
- end-to-end |
|
- full-page |
|
- system-level |
|
annotations_creators: |
|
- manually expert-generated |
|
pretty_name: Sheet Music Benchmark |
|
size_categories: |
|
- 1K<n<10K |
|
task_categories: |
|
- image-to-text |
|
- image-segmentation |
|
- text-retrieval |
|
subtasks: |
|
- document-retrieval |
|
extra_gated_fields: |
|
Affiliation: text |
|
--- |
|
|
|
|
|
# ⚠️ Work in Progress! SMB: A Multi-Texture Sheet Music Recognition Benchmark ⚠️ |
|
|
|
## Overview |
|
|
|
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. |
|
|
|
## Use Cases: |
|
- Optical Music Recognition (OMR): system-level, full-page |
|
- Image Segmentation: music regions |
|
|
|
## Dataset Details |
|
|
|
Each page includes the corresponding \**kern data for that specific page. Additionally, it provides detailed annotations for each region within the page. |
|
|
|
### 1. Image |
|
- **Type**: PNG |
|
- **Description**: Encoded full-page image of the score. |
|
|
|
### 2. Original Width |
|
- **Type**: Integer |
|
- **Description**: The width of the image in pixels. |
|
|
|
### 3. Original Height |
|
- **Type**: Integer |
|
- **Description**: The height of the image in pixels. |
|
|
|
### 4. Regions |
|
- **Type**: List of JSON objects |
|
- **Description**: Contains detailed information about regions on the page. Each JSON object includes: |
|
- **bbox**: |
|
- **x**: The vertical position on the page (in pixels). |
|
- **y**: The horizontal position on the page (in pixels). |
|
- **width**: Width of the region (in pixels). |
|
- **height**: Height of the region (in pixels). |
|
- **rotation**: Angle of rotation (in degrees) for the bounding box around its top-left corner. This angle defines how much the box is rotated clockwise from its default unrotated position. |
|
- **raw**: The content extracted from the original dataset before any processing. |
|
- **kern**: A standardized version of the content ready for rendering. |
|
- **ekern**: A tokenized and standardized version of the content for enhanced processing. |
|
|
|
### 5. Page Texture |
|
- **Type**: String |
|
- **Description**: The musical texture of the page. |
|
- **Values**: |
|
- "Pianoform" |
|
- "Monophonic" |
|
- "Other" |
|
|
|
### 6. Page |
|
- **Type**: JSON object |
|
- **Description**: Metadata of the page. Fields include: |
|
- **raw**: The unprocessed content extracted from the original dataset. |
|
- **kern**: The content in a standardized format, ready to be rendered. |
|
- **ekern**: The content in a tokenized and standardized format. |
|
|
|
### 7. Score ID |
|
- **Type**: String |
|
- **Description**: Unique identifier for the original score to which the page belongs. |
|
|
|
|
|
## SMB usage 📖 |
|
SMB is publicly available at [HuggingFace](https://huggingface.co/datasets/PRAIG/SMB). |
|
|
|
To download from HuggingFace: |
|
|
|
1. Gain access to the dataset and get your HF access token from: [https://huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). |
|
2. Install dependencies and login HF: |
|
- Install Python |
|
- Run `pip install pillow datasets huggingface_hub[cli]` |
|
- Login by `huggingface-cli login` and paste the HF access token. Check [here](https://huggingface.co/docs/huggingface_hub/guides/cli#huggingface-cli-login) for details. |
|
3. Use the following code to load SMB and extract the regions: |
|
|
|
|
|
```python |
|
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["train"] |
|
|
|
# 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...") |
|
|
|
``` |
|
|
|
## Citation |
|
|
|
If you use our work, please cite us: |
|
|
|
```bibtex |
|
@preprint{, |
|
author = {, |
|
title = {}, |
|
year = {} |
|
} |
|
``` |