Publish TextSeg-refined v2 checkpoint and SFX 0.20 settings
Browse filesReplaces the deployment weights with the epoch-7 best checkpoint from the 8xH100 Manga109 Segmentation v2.0.0 run. Updates validation metrics, provenance, and class-specific inference thresholds.
- README.md +49 -37
- inference_config.json +3 -2
- model.safetensors +1 -1
- validation_metrics.json +19 -18
README.md
CHANGED
|
@@ -37,9 +37,9 @@ The model does **not** perform OCR or reading-order prediction.
|
|
| 37 |
- `inference_config.json` — class mapping and recommended inference settings
|
| 38 |
- `validation_metrics.json` — final held-out validation results
|
| 39 |
|
| 40 |
-
The
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
## Usage
|
| 45 |
|
|
@@ -51,6 +51,7 @@ pip install "rfdetr==1.7.0" "safetensors>=0.5" huggingface_hub pillow
|
|
| 51 |
from huggingface_hub import hf_hub_download
|
| 52 |
from PIL import Image
|
| 53 |
import importlib.util
|
|
|
|
| 54 |
|
| 55 |
weights = hf_hub_download(
|
| 56 |
repo_id="mayocream/koharu-layout-rfdetr-seg-2xl-1152",
|
|
@@ -68,11 +69,18 @@ model = loader.load_model(weights)
|
|
| 68 |
image = Image.open("page.jpg").convert("RGB")
|
| 69 |
detections = model.predict(
|
| 70 |
image,
|
| 71 |
-
threshold=0.
|
| 72 |
shape=(1152, 1152),
|
| 73 |
include_source_image=False,
|
| 74 |
)
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
print(detections.xyxy) # bounding boxes
|
| 77 |
print(detections.mask) # instance masks
|
| 78 |
print(detections.class_id) # 0=text, 1=COO, 2=bubble, 3=panel
|
|
@@ -83,43 +91,46 @@ CUDA is strongly recommended. The model was trained and evaluated at 1152 px.
|
|
| 83 |
|
| 84 |
## Recommended thresholds
|
| 85 |
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
| Class | Suggested threshold |
|
| 90 |
|---|---:|
|
| 91 |
-
| Text | 0.25
|
| 92 |
-
| COO | 0.
|
| 93 |
| Bubble | 0.50 |
|
| 94 |
| Panel | 0.50 |
|
| 95 |
|
| 96 |
-
The lower
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
## Validation results
|
| 100 |
|
| 101 |
-
The final checkpoint was evaluated on the held-out 1,
|
| 102 |
-
split at 1152 px.
|
| 103 |
|
| 104 |
| Metric | Score |
|
| 105 |
|---|---:|
|
| 106 |
-
| Box mAP50–95 | 0.
|
| 107 |
-
| Box mAP50 | 0.
|
| 108 |
-
| Box mAP75 | 0.
|
| 109 |
-
| Mask mAP50–95 | 0.
|
| 110 |
-
| Mask mAP50 | 0.
|
| 111 |
-
| Detection precision | 0.
|
| 112 |
-
| Detection recall | 0.
|
| 113 |
-
| Detection F1 | 0.
|
| 114 |
|
| 115 |
Per-class box AP:
|
| 116 |
|
| 117 |
| Class | AP |
|
| 118 |
|---|---:|
|
| 119 |
-
| Text | 0.
|
| 120 |
-
| COO | 0.
|
| 121 |
-
| Bubble | 0.
|
| 122 |
-
| Panel | 0.
|
| 123 |
|
| 124 |
## Out-of-domain review
|
| 125 |
|
|
@@ -129,31 +140,32 @@ annotations, so the observations below are visual rather than accuracy claims.
|
|
| 129 |
|
| 130 |
- Dialogue text, bubbles, and conventional panel layouts generalized well.
|
| 131 |
- Marriage Toxin dialogue, bubbles, and panels were particularly consistent.
|
| 132 |
-
-
|
| 133 |
-
|
| 134 |
- Covers, logos, credits, and dense collage layouts remain difficult.
|
| 135 |
-
-
|
| 136 |
-
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
## Training
|
| 139 |
|
| 140 |
- Architecture: RF-DETR Seg 2XL (`rfdetr==1.7.0`)
|
| 141 |
- Resolution: 1152 × 1152
|
| 142 |
-
- Main supervision: Manga109 Segmentation
|
|
|
|
| 143 |
- Classes: text, onomatopoeia, bubble, panel
|
| 144 |
-
- Final continuation stage:
|
| 145 |
- Final-stage global batch: 32 (8 GPUs × 2 images × 2 accumulation steps)
|
| 146 |
- Optimizer learning rate: `3e-5`; encoder learning rate: `1e-5`
|
| 147 |
- EMA enabled; seed 42
|
| 148 |
-
-
|
| 149 |
-
|
| 150 |
-
The auxiliary typography head used for training improved mask recall but did
|
| 151 |
-
not materially improve box AP. It is intentionally excluded from this
|
| 152 |
-
deployment checkpoint.
|
| 153 |
|
| 154 |
## Limitations
|
| 155 |
|
| 156 |
-
- COO
|
| 157 |
- Large display titles and credits may be missed or assigned low confidence.
|
| 158 |
- Character nameplates and small icons can be confused with bubbles.
|
| 159 |
- Dense collages can create many duplicate or low-confidence instances.
|
|
@@ -178,5 +190,5 @@ images or to third-party comic content.
|
|
| 178 |
SHA-256:
|
| 179 |
|
| 180 |
```text
|
| 181 |
-
|
| 182 |
```
|
|
|
|
| 37 |
- `inference_config.json` — class mapping and recommended inference settings
|
| 38 |
- `validation_metrics.json` — final held-out validation results
|
| 39 |
|
| 40 |
+
The SafeTensors weights are the epoch-7 best checkpoint from the TextSeg-refined
|
| 41 |
+
Manga109 Segmentation v2.0.0 training run. They contain only the standard
|
| 42 |
+
RF-DETR Seg 2XL model state; no custom dense head is required.
|
| 43 |
|
| 44 |
## Usage
|
| 45 |
|
|
|
|
| 51 |
from huggingface_hub import hf_hub_download
|
| 52 |
from PIL import Image
|
| 53 |
import importlib.util
|
| 54 |
+
import numpy as np
|
| 55 |
|
| 56 |
weights = hf_hub_download(
|
| 57 |
repo_id="mayocream/koharu-layout-rfdetr-seg-2xl-1152",
|
|
|
|
| 69 |
image = Image.open("page.jpg").convert("RGB")
|
| 70 |
detections = model.predict(
|
| 71 |
image,
|
| 72 |
+
threshold=0.20,
|
| 73 |
shape=(1152, 1152),
|
| 74 |
include_source_image=False,
|
| 75 |
)
|
| 76 |
|
| 77 |
+
class_thresholds = {0: 0.25, 1: 0.20, 2: 0.50, 3: 0.50}
|
| 78 |
+
keep = np.asarray([
|
| 79 |
+
score >= class_thresholds[int(class_id)]
|
| 80 |
+
for class_id, score in zip(detections.class_id, detections.confidence)
|
| 81 |
+
])
|
| 82 |
+
detections = detections[keep]
|
| 83 |
+
|
| 84 |
print(detections.xyxy) # bounding boxes
|
| 85 |
print(detections.mask) # instance masks
|
| 86 |
print(detections.class_id) # 0=text, 1=COO, 2=bubble, 3=panel
|
|
|
|
| 91 |
|
| 92 |
## Recommended thresholds
|
| 93 |
|
| 94 |
+
Run prediction at the lowest threshold below, then apply class-specific
|
| 95 |
+
filtering:
|
| 96 |
|
| 97 |
| Class | Suggested threshold |
|
| 98 |
|---|---:|
|
| 99 |
+
| Text | 0.25 |
|
| 100 |
+
| COO / SFX | 0.20 |
|
| 101 |
| Bubble | 0.50 |
|
| 102 |
| Panel | 0.50 |
|
| 103 |
|
| 104 |
+
The lower SFX threshold is intentional. On a 291-page out-of-domain comparison,
|
| 105 |
+
changing only SFX from 0.40 to 0.20 raised typography-mask recall against
|
| 106 |
+
TextSeg from 72.98% to 79.51% and raw mask IoU from 58.37% to 61.75%. It is
|
| 107 |
+
particularly helpful for large stylized effects. For applications that favor
|
| 108 |
+
precision over pre-inpainting recall, raise the SFX threshold toward 0.40.
|
| 109 |
|
| 110 |
## Validation results
|
| 111 |
|
| 112 |
+
The final checkpoint was evaluated on the held-out 1,001-page TextSeg-refined
|
| 113 |
+
Manga109 validation split at 1152 px.
|
| 114 |
|
| 115 |
| Metric | Score |
|
| 116 |
|---|---:|
|
| 117 |
+
| Box mAP50–95 | 0.7969 |
|
| 118 |
+
| Box mAP50 | 0.8970 |
|
| 119 |
+
| Box mAP75 | 0.8425 |
|
| 120 |
+
| Mask mAP50–95 | 0.5713 |
|
| 121 |
+
| Mask mAP50 | 0.8256 |
|
| 122 |
+
| Detection precision | 0.8767 |
|
| 123 |
+
| Detection recall | 0.8177 |
|
| 124 |
+
| Detection F1 | 0.8392 |
|
| 125 |
|
| 126 |
Per-class box AP:
|
| 127 |
|
| 128 |
| Class | AP |
|
| 129 |
|---|---:|
|
| 130 |
+
| Text | 0.8779 |
|
| 131 |
+
| COO | 0.4431 |
|
| 132 |
+
| Bubble | 0.9092 |
|
| 133 |
+
| Panel | 0.9574 |
|
| 134 |
|
| 135 |
## Out-of-domain review
|
| 136 |
|
|
|
|
| 140 |
|
| 141 |
- Dialogue text, bubbles, and conventional panel layouts generalized well.
|
| 142 |
- Marriage Toxin dialogue, bubbles, and panels were particularly consistent.
|
| 143 |
+
- SFX at threshold 0.20 recovered substantially more large stylized effects on
|
| 144 |
+
the Blue Archive pages, with a small precision cost.
|
| 145 |
- Covers, logos, credits, and dense collage layouts remain difficult.
|
| 146 |
+
- Very decorative marks can be accepted as SFX at the recommended low threshold.
|
| 147 |
+
|
| 148 |
+
TextSeg was used as the comparison reference for this review, not human ground
|
| 149 |
+
truth. After 4 px reference-scale dilation and hole filling, RF-DETR/TextSeg
|
| 150 |
+
mask IoU increased from 79.18% at SFX 0.40 to 82.27% at SFX 0.20.
|
| 151 |
|
| 152 |
## Training
|
| 153 |
|
| 154 |
- Architecture: RF-DETR Seg 2XL (`rfdetr==1.7.0`)
|
| 155 |
- Resolution: 1152 × 1152
|
| 156 |
+
- Main supervision: Manga109 Segmentation v2.0.0, with PP-DocLayoutV3 boxes and
|
| 157 |
+
TextSeg-refined typography masks
|
| 158 |
- Classes: text, onomatopoeia, bubble, panel
|
| 159 |
+
- Final continuation stage: 8 epochs; best checkpoint at epoch 7
|
| 160 |
- Final-stage global batch: 32 (8 GPUs × 2 images × 2 accumulation steps)
|
| 161 |
- Optimizer learning rate: `3e-5`; encoder learning rate: `1e-5`
|
| 162 |
- EMA enabled; seed 42
|
| 163 |
+
- Training hardware: 8 × NVIDIA H100 80 GB
|
| 164 |
+
- No custom dense head or typography-distillation branch
|
|
|
|
|
|
|
|
|
|
| 165 |
|
| 166 |
## Limitations
|
| 167 |
|
| 168 |
+
- COO remains weaker than text, bubble, and panel detection.
|
| 169 |
- Large display titles and credits may be missed or assigned low confidence.
|
| 170 |
- Character nameplates and small icons can be confused with bubbles.
|
| 171 |
- Dense collages can create many duplicate or low-confidence instances.
|
|
|
|
| 190 |
SHA-256:
|
| 191 |
|
| 192 |
```text
|
| 193 |
+
9bf6d2cbd7793c956d8c857bb1672a396eb7f100eb0682f86830d05e31168efb
|
| 194 |
```
|
inference_config.json
CHANGED
|
@@ -11,10 +11,11 @@
|
|
| 11 |
},
|
| 12 |
"recommended_thresholds": {
|
| 13 |
"text": 0.25,
|
| 14 |
-
"onomatopoeia": 0.
|
| 15 |
"bubble": 0.5,
|
| 16 |
"panel": 0.5
|
| 17 |
},
|
| 18 |
"checkpoint": "model.safetensors",
|
| 19 |
-
"checkpoint_sha256": "
|
|
|
|
| 20 |
}
|
|
|
|
| 11 |
},
|
| 12 |
"recommended_thresholds": {
|
| 13 |
"text": 0.25,
|
| 14 |
+
"onomatopoeia": 0.2,
|
| 15 |
"bubble": 0.5,
|
| 16 |
"panel": 0.5
|
| 17 |
},
|
| 18 |
"checkpoint": "model.safetensors",
|
| 19 |
+
"checkpoint_sha256": "9bf6d2cbd7793c956d8c857bb1672a396eb7f100eb0682f86830d05e31168efb",
|
| 20 |
+
"source_checkpoint_sha256": "b1f8c81e41e376342cb9e236be265505a96dc0c3774916df17cad4d720e3b67a"
|
| 21 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 161292684
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9bf6d2cbd7793c956d8c857bb1672a396eb7f100eb0682f86830d05e31168efb
|
| 3 |
size 161292684
|
validation_metrics.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
| 1 |
{
|
| 2 |
-
"dataset": "Manga109 Segmentation
|
| 3 |
-
"pages":
|
| 4 |
"resolution": 1152,
|
| 5 |
-
"checkpoint_epoch":
|
| 6 |
"metrics": {
|
| 7 |
-
"box_map_50_95": 0.
|
| 8 |
-
"box_map_50": 0.
|
| 9 |
-
"box_map_75": 0.
|
| 10 |
-
"box_mar": 0.
|
| 11 |
-
"precision": 0.
|
| 12 |
-
"recall": 0.
|
| 13 |
-
"f1": 0.
|
| 14 |
-
"mask_map_50_95": 0.
|
| 15 |
-
"mask_map_50": 0.
|
| 16 |
"box_ap_by_class": {
|
| 17 |
-
"text": 0.
|
| 18 |
-
"onomatopoeia": 0.
|
| 19 |
-
"bubble": 0.
|
| 20 |
-
"panel": 0.
|
| 21 |
}
|
| 22 |
-
}
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
-
|
|
|
|
| 1 |
{
|
| 2 |
+
"dataset": "Manga109 Segmentation v2.0.0 TextSeg-refined validation split",
|
| 3 |
+
"pages": 1001,
|
| 4 |
"resolution": 1152,
|
| 5 |
+
"checkpoint_epoch": 7,
|
| 6 |
"metrics": {
|
| 7 |
+
"box_map_50_95": 0.7968884706497192,
|
| 8 |
+
"box_map_50": 0.8969718217849731,
|
| 9 |
+
"box_map_75": 0.8424826264381409,
|
| 10 |
+
"box_mar": 0.8537694215774536,
|
| 11 |
+
"precision": 0.8767244219779968,
|
| 12 |
+
"recall": 0.8176969885826111,
|
| 13 |
+
"f1": 0.8392113447189331,
|
| 14 |
+
"mask_map_50_95": 0.5712965726852417,
|
| 15 |
+
"mask_map_50": 0.8256368041038513,
|
| 16 |
"box_ap_by_class": {
|
| 17 |
+
"text": 0.8779019117355347,
|
| 18 |
+
"onomatopoeia": 0.4430747330188751,
|
| 19 |
+
"bubble": 0.9092085957527161,
|
| 20 |
+
"panel": 0.9573686122894287
|
| 21 |
}
|
| 22 |
+
},
|
| 23 |
+
"checkpoint_sha256": "b1f8c81e41e376342cb9e236be265505a96dc0c3774916df17cad4d720e3b67a",
|
| 24 |
+
"validation_mode": "single GPU after 8-GPU DDP training"
|
| 25 |
}
|
|
|