MA-Net Speech Bubble Segmentation

MA-Net model for segmenting speech bubbles in webtoon and manga images.

This checkpoint was trained for use in the public TOONTRA reconstruction.

Model

  • Architecture: MA-Net
  • Encoder: ResNet34
  • Framework: PyTorch
  • Implementation: segmentation-models-pytorch
  • Input size: 512 × 512
  • Output: Binary speech-bubble mask
  • Inference threshold: 0.45

Training Data

The model was trained on:

Roboflow manga-segment_v2, version 5

The dataset is not redistributed in this repository and remains subject to its original license and terms.

Training Configuration

Parameter Value
Architecture MA-Net
Encoder ResNet34
Input size 512 × 512
Crop padding 15%
Loss Dice + BCE
Optimizer AdamW
Batch size 8
Best epoch 18
Threshold 0.45

Evaluation

Metric Score
Validation Dice 0.9828
Test Dice 0.9805
Test IoU 0.9622

Loading the Model

import torch
import segmentation_models_pytorch as smp

checkpoint = torch.load(
    "manet_bubble_segmentation.pth",
    map_location="cpu",
    weights_only=True,
)

model = smp.MAnet(
    encoder_name="resnet34",
    encoder_weights=None,
    in_channels=3,
    classes=1,
)

model.load_state_dict(checkpoint["state_dict"], strict=True)
model.eval()

threshold = float(checkpoint["threshold"])

The model expects RGB speech-bubble crops. Preserve the crop aspect ratio, resize it to fit inside a 512 × 512 canvas, and center it on a white background. Normalize the image with ImageNet mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225].

Apply sigmoid to the model output and use the checkpoint threshold (0.45) to obtain the binary mask. Remove the letterbox padding and resize the mask back to the original crop size with nearest-neighbor interpolation.

Intended Use

The model is intended for speech-bubble segmentation in webtoon and manga images.

It expects an approximate speech-bubble crop rather than a complete long webtoon page. A separate detector can be used to locate the bubble before segmentation.

Limitations

Performance may be lower for unusual bubble styles, transparent bubbles, poorly defined boundaries, or image styles substantially different from the training data.

License

The checkpoint is released under the Apache License 2.0.

Third-party datasets and libraries remain subject to their respective licenses and terms.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support