CoolFace
Modelpublic

huyvux3005/manga109-segmentation-bubble

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
23likes4.9kdownloads
Model Card

๐ŸŽฏ MangaLens - Manga Speech Bubble Segmentation

<div align="center">

Model Task mAP50 License

</div>

A high-performance YOLO11n instance segmentation model fine-tuned for detecting and segmenting speech bubbles in manga/comic images.

๏ฟฝ๏ธ Demo Results

<div align="center">

Detection on Various Manga Styles
[image]
Speech bubble detection on action manga with multiple bubbles
![Demo 2](assets/demo2.jpg)
Detection on slice-of-life manga style

</div>

๏ฟฝ๐Ÿ“Š Model Performance

Final Evaluation Results (Epoch 44)

MetricBox DetectionMask Segmentation
Precision97.55%97.66%
Recall97.03%97.15%
mAP@5099.10%99.13%
mAP@50-9596.67%94.69%

Training Curves

<div align="center">

[image] Left: Segmentation Loss (Train vs Val) | Right: Mask mAP Metrics over epochs

</div>

Loss TypeFinal Value
Box Loss0.2499
Segmentation Loss0.2762
Classification Loss0.2109
DFL Loss0.8064

๐ŸŽ“ Training Configuration

ParameterValue
Base Modelyolo11n-seg.pt
Image Size1600ร—1600
Batch Size8
Epochs100 (Early stopped at 44)
OptimizerAuto (AdamW)
Learning Rate0.01
Weight Decay0.0005
Patience10
AMPEnabled

Data Augmentation

  • โ€”HSV Augmentation: H=0.015, S=0.7, V=0.4
  • โ€”Mosaic: 1.0
  • โ€”Flip Left-Right: 0.5
  • โ€”Scale: 0.5
  • โ€”Translate: 0.1

๐Ÿ“š Training Data

This model was trained on a combined dataset of:

  1. 1.[MS92/MangaSegmentation](https://huggingface.co/datasets/MS92/MangaSegmentation) - Manga panel and bubble segmentation dataset
  2. 2.[Manga109](http://www.manga109.org/) - Large-scale manga dataset with speech bubble annotations

๐Ÿš€ Quick Start

Installation

bash
pip install ultralytics>=8.0.0

Inference

python
from ultralytics import YOLO

# Load the model
model = YOLO("best.pt")

# Run inference on an image
results = model("manga_page.jpg")

# Process results
for result in results:
    # Get bounding boxes
    boxes = result.boxes
    
    # Get segmentation masks
    masks = result.masks
    
    # Visualize results
    result.show()
    
    # Save results
    result.save("output.jpg")

Batch Processing

python
from ultralytics import YOLO
from pathlib import Path

model = YOLO("best.pt")

# Process multiple images
image_folder = Path("manga_pages/")
results = model(list(image_folder.glob("*.jpg")), stream=True)

for i, result in enumerate(results):
    result.save(f"output_{i}.jpg")

Extract Bubble Regions

python
import cv2
import numpy as np
from ultralytics import YOLO

model = YOLO("best.pt")
image = cv2.imread("manga_page.jpg")
results = model(image)[0]

# Extract each bubble as a separate image
for i, mask in enumerate(results.masks.data):
    mask_np = mask.cpu().numpy()
    mask_resized = cv2.resize(mask_np, (image.shape[1], image.shape[0]))
    
    # Apply mask
    bubble = image.copy()
    bubble[mask_resized < 0.5] = 0
    
    # Get bounding box and crop
    coords = np.where(mask_resized >= 0.5)
    if len(coords[0]) > 0:
        y_min, y_max = coords[0].min(), coords[0].max()
        x_min, x_max = coords[1].min(), coords[1].max()
        cropped = bubble[y_min:y_max, x_min:x_max]
        cv2.imwrite(f"bubble_{i}.png", cropped)

๐Ÿ“ Model Files

weights/
โ”œโ”€โ”€ best.pt      # Best checkpoint (recommended)
โ””โ”€โ”€ last.pt      # Last training checkpoint

๐ŸŽฏ Use Cases

  • โ€”Manga Translation: Automatically detect speech bubbles for text extraction and translation
  • โ€”Manga Analysis: Study panel layouts and dialogue distribution
  • โ€”Content Moderation: Identify and process text regions in comics
  • โ€”Accessibility: Enable text-to-speech for manga readers
  • โ€”Dataset Creation: Generate annotations for manga datasets

โš™๏ธ Technical Details

Model Architecture

  • โ€”Backbone: YOLO11n (Nano variant)
  • โ€”Task: Instance Segmentation
  • โ€”Classes: 1 (Speech Bubble)
  • โ€”Input: RGB images (any size, recommended 1600ร—1600)
  • โ€”Output: Bounding boxes + Instance masks

Inference Speed

DeviceSpeed (ms/image)
GPU (T4)~15-25 ms
GPU (V100)~8-12 ms
CPU~200-400 ms

๐Ÿ“ Citation

If you use this model in your research, please cite:

bibtex
@misc{mangalens2024,
  title={MangaLens: YOLO11n Speech Bubble Segmentation Model},
  author={MangaLens Team},
  year={2024},
  publisher={Hugging Face},
  url={https://huggingface.co/your-username/mangalens-bubble-segmentation}
}

๐Ÿ“œ License

This model is released under the Apache 2.0 License.

๐Ÿ™ Acknowledgements


<div align="center"> <b>Made with โค๏ธ for the manga community</b> </div>