--- pretty_name: Manga Layout license: other viewer: false language: - ja - en - zh task_categories: - object-detection - image-segmentation tags: - manga - comics - layout-analysis - instance-segmentation - text-detection - onomatopoeia - benchmark --- # Manga Layout Segmentation of **text, sound effects (onomatopoeia), balloons and panels** on classic and modern manga pages, for training layout models and for benchmarking what a manga translator needs: every piece of lettering found, nothing on the art taken for lettering, and masks that remove the lettering without eating the art around it. Annotations are COCO JSON with RLE masks. **Images are not included except for `western`**, whose licences allow it; see *Getting the images*. ## Subsets | Subset | Pages | Train | Validation | Test | Images | |---|---|---:|---:|---:|---| | `danbooru` | modern, often colour or translated comics, and illustrations with drawn marks, from Danbooru2024 | 9,059 | 107 | 398 | fetched by post id, checked by md5 (`fetch_danbooru.py`) | | `manga109` | classic monochrome manga, Manga109 | 8,128 | 1,001 | 969 | from the Manga109 release | | `western` | Pepper&Carrot, Golden Age comics, David Revoy's artworks | 1,131 | 107 | — | included | Splits share no artist (`danbooru`) or title (`manga109`). Report each subset on its own; `danbooru` is the headline. ## What is labelled Categories: `text` (1), `onomatopoeia` (2), `bubble` (3), `panel` (4). - `text` carries a `role` where it was reviewed: dialogue, narration, aside, title, sign, name_tag, header, page_number or credit. - `iscrowd: 1` is an ignore region: lettering whose class is unsure, a sign or other in-world text, or a class the page doesn't label (the `danbooru` test and validation pages label text and onomatopoeia only, and mark balloons and panels as whole-page ignore regions). - `attributes.has_mask: false` marks a label with a box and no mask. - `attributes.quality_tier`: `gold_reviewed` for `danbooru` test onomatopoeia whose masks were reviewed one by one; `gold_zenodo_refined` for `manga109` labels backed by the Zenodo hand-painted masks. - `danbooru` images carry `danbooru_id`, `md5`, `rating` (g, s, q, e), `artists` and `kind` (comic, lettered, illustration, chibi). Train keeps pages of every rating; validation and test hold general and sensitive pages only. ## How the labels were made **`danbooru`** - *Comics* (1,398 train pages from about a thousand artists): every text and onomatopoeia reviewed by hand, with roles. Text masks are its ink; onomatopoeia masks are strokes from [`mayocream/koharu-text-sam-ts-l`](https://huggingface.co/mayocream/koharu-text-sam-ts-l) (Hi-SAM's SAM-TS), model-made and not graded one by one. - *Lettered posts* (2,874): a layout model's draft corrected by review and by Danbooru's translator notes; anything unsure is an ignore region. Their onomatopoeia take SAM-TS strokes. A lower tier than the comics. - *Illustrations and chibi illustrations* (4,787): pages with drawn marks (sweat drops, anger veins, sparkles, motion lines) and no lettering, the negatives a model needs; lettering review found is an ignore region. - *Test* (398 pages, 329 artists): every text and onomatopoeia reviewed, plus a pass over every model's detections on art to complete the labels. 840 of its 1,128 onomatopoeia have a reviewed mask: SAM-TS strokes graded OK one by one, some grown over the white outline band around colour lettering and checked again. **`manga109`** is manga109-segmentation 5.4.0. Over the published v3.0.0 it trims machine-made masks to their ink, fits onomatopoeia boxes to their ink, chooses each flagged onomatopoeia's mask by review among candidates (10,852 instances), reviews validation and test onomatopoeia stroke by stroke (1,776 labels), and marks 2,825 pieces of lettering COO left unlabelled as ignore regions after review. Its v3.0.0 numbers are not comparable with these. **`western`** - *Pepper&Carrot* (episodes 1–39 in English, Japanese and Chinese; validation is episodes 14, 24 and 34): rendered from the comic's SVG sources with its fonts, masks from the SVG's own objects, panels ignored. - *Golden Age comics* (validation is Fantastic Comics #17): boxes reviewed by hand, with text roles; page numbers ignored. - *Revoy's artworks*: negatives; signatures and signs ignored. ## Getting the images - `danbooru`: accept the terms of [deepghs/danbooru2024-webp-4Mpixel](https://huggingface.co/datasets/deepghs/danbooru2024-webp-4Mpixel), run `hf auth login`, then `pip install cheesechaser` and `python fetch_danbooru.py`. Images land in `danbooru/images/`. Posts deleted or replaced since the snapshot are listed in `danbooru/unavailable.json`, and `score.py` leaves those pages out; say how many when you report. - `manga109`: obtain Manga109 from the [Manga109 project](http://www.manga109.org/) under its terms; `file_name` is relative to its `images/` folder. - `western`: in `western/images/`. ## Benchmark ```sh python score.py danbooru test predictions.json --text --onomatopoeia ``` Predictions are COCO results (`image_id`, `category_id`, `bbox`, `score`, optional RLE `segmentation`). Give your model's own published thresholds; never tune them on a test split. It reports: | Measure | Meaning | |---|---| | **Page accuracy (PA)** | share of pages with no story text or onomatopoeia missed and no false positive | | **Text recall** | share of dialogue, narration, aside and title texts at least half covered by kept text or onomatopoeia boxes | | **SFX recall** | the same for onomatopoeia | | **False positives per image (FPPI)** | kept boxes with under a tenth of their area on the page's labels and ignore regions, summed | | **Full-coverage rate (FCR)** | share of reviewed onomatopoeia masks at least 99% covered by the kept masks, grown by 2 px per 1,024 px of the page's long side plus 3 px | | **Residual ink (RI)** | share of the reviewed onomatopoeia's ink the grown masks leave uncovered | | **Excess mask ratio (EMR)** | grown mask area outside the page's grown lettering, over that lettering's area | | **Box and mask AP** | COCO AP50 and AP50–95 per class; labels without a mask are ignore regions for mask AP | Report parameters and time per image on a named GPU alongside. ## Licence and sources `license: other` because the subsets carry different terms: - `danbooru` and `western` annotations: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Danbooru images are their artists' and are not included. - `western` images: Pepper&Carrot and artworks by David Revoy, www.peppercarrot.com, [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), translations by the Pepper&Carrot translators credited on each episode; Exciting Comics #6, #18, #44, #59 (Nedor) and Fantastic Comics #17 (Fox), public domain, scans from archive.org. - `manga109` annotations derive from manga109-segmentation and follow its upstream terms: [Manga109](http://www.manga109.org/), [MangaSegmentation](https://huggingface.co/datasets/MS92/MangaSegmentation), [COO](https://github.com/ku21fan/COO-Comic-Onomatopoeia), the [Zenodo manga text masks](https://doi.org/10.5281/zenodo.4511796) (CC BY 4.0), and the models named in manga109-segmentation's card. The dataset grants no licence for Manga109 images. `build.json` records the source versions, counts and checksums.