Downloads · 30 days
77
35% of all-time downloads
mayocream/koharu-text-sam-ts-l
koharu-text-sam-ts-l is a image segmentation model from mayocream. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for pytorch. The card lists the license as apache-2.0.
koharu-text-sam-ts-l is a ViT-L Hi-SAM/SAM-TS TextSeg model fine-tuned for binary text segmentation on manga pages. It detects text pixels rather than speech balloons, panels, or individual text lines.
Downloads · 30 days
77
35% of all-time downloads
All-time downloads
218
Public
Parameters
339M
1.5 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.5 GB · 100%
From the Hugging Face model README
koharu-text-sam-ts-l is a ViT-L Hi-SAM/SAM-TS TextSeg model fine-tuned for
binary text segmentation on manga pages. It detects text pixels rather than
speech balloons, panels, or individual text lines.
The model was fine-tuned from the SAM-TS-L TextSeg checkpoint from Hi-SAM. The released weights use SafeTensors only; no pickle checkpoint is required for the full model.
| File | Contents |
|---|---|
model.safetensors | Complete merged model state: 728 tensors, 338,934,897 elements |
adapter_model.safetensors | Fine-tuned trainable state only: 366 tensors, 30,650,149 elements |
config.json | Architecture, preprocessing, and training configuration |
evaluation.json | Aggregate book-disjoint evaluation results |
inference.py | Minimal loading and full-page inference example |
Use model.safetensors unless you specifically need the smaller adapter state.
The full file loads strictly into a freshly constructed SAM-TS-L model and does
not require the original SAM or TextSeg .pth files.
Metrics use micro-averaged binary pixel counts. HR refers to the high-resolution SAM-TS output.
| Split | Model | HR IoU | HR F-score | HR precision | HR recall |
|---|---|---|---|---|---|
| Validation, 50 pages / 5 books | Original TextSeg | 0.4138 | 0.5854 | 0.8788 | 0.4388 |
| Validation, 50 pages / 5 books | Koharu Text SAM-TS-L | 0.7062 | 0.8278 | 0.8513 | 0.8056 |
| Test, 40 pages / 4 unseen books | Original TextSeg | 0.3461 | 0.5142 | 0.8365 | 0.3712 |
| Test, 40 pages / 4 unseen books | Koharu Text SAM-TS-L | 0.6285 | 0.7719 | 0.7786 | 0.7653 |
The fine-tuned model improved HR IoU on 39 of the 40 test pages. Test HR IoU ranged from 0.5616 to 0.6977 across the four held-out books.
Training used the masks from Mask Dataset for: Unconstrained Text Detection in Manga: a New Dataset and Baseline by Julian del Gobbo and Rosana Matuk Herrera, licensed CC BY 4.0, paired locally with authorized Manga109 images. Manga109 images are not included in this model repository.
The split was deterministic and book-disjoint:
The training stream contained 1,795 entries: 1,436 native 1024×1024 crops
(80%) and 359 full pages resized and padded to 1024×1024 (20%). This model was
not trained with the mayocream/manga109-segmentation dataset.
1e-51e-6Clone Hi-SAM and install its dependencies,
plus huggingface_hub and safetensors. The included command-line example
loads the complete SafeTensors state and writes a binary PNG mask:
python inference.py input-page.jpg output-mask.png --hi-sam-root /path/to/Hi-SAM
Equivalent model-loading code:
from types import SimpleNamespace
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
from hi_sam.modeling.build import model_registry
args = SimpleNamespace(
checkpoint=None,
model_type="vit_l",
attn_layers=1,
prompt_len=12,
hier_det=False,
)
model = model_registry["vit_l"](args=args)
weights = hf_hub_download(
"mayocream/koharu-text-sam-ts-l", "model.safetensors"
)
model.load_state_dict(load_file(weights, device="cpu"), strict=True)
model = model.eval().cuda()
Inputs are RGB tensors in the 0–255 range. Resize the page so its longest side
is 1024 pixels, pad the bottom and right sides to 1024×1024 with RGB value 128,
and crop away the padding from the predicted mask before resizing it back to
the original page size. inference.py implements this exact preprocessing.
transformers.AutoModel or the hosted Hugging Face inference widget.The complete SafeTensors file was loaded with strict=True and reevaluated on
all validation and test pages. It reproduced the original fine-tuned checkpoint
metrics exactly in the local CUDA 13 evaluation environment.
| Artifact | SHA-256 |
|---|---|
model.safetensors | bcd9525291677f467f0603509a0ca3df35711b4e3417cefce8da6bfc97164f45 |
adapter_model.safetensors | 78fd7140e5f8728c8d07f97163535c649390077811aad90e0e418c80504d8242 |
| source epoch-20 checkpoint | ebe1ed2bec50659dd4d22bd9fdb017117c15d5bc2acbef4588dfe3baf4d723f8 |
The model is released under Apache License 2.0, matching Hi-SAM and Segment Anything. The training masks are CC BY 4.0 and are attributed above. Use of Manga109 imagery remains subject to the Manga109 terms; no Manga109 images are redistributed here.