Image Segmentation
ultralytics
Tibetan
tibetan
document-ai
line-segmentation
instance-segmentation
yolo11
Instructions to use TibetanCodexAITeam/PechaBridgeLineSegmentation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use TibetanCodexAITeam/PechaBridgeLineSegmentation with ultralytics:
# Couldn't find a valid YOLO version tag. # Replace XX with the correct version. from ultralytics import YOLOvXX model = YOLOvXX.from_pretrained("TibetanCodexAITeam/PechaBridgeLineSegmentation") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Add PechaBridge line-segmentation model card
Browse files
README.md
CHANGED
|
@@ -1,3 +1,129 @@
|
|
| 1 |
-
---
|
| 2 |
-
|
| 3 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- bo
|
| 4 |
+
license: agpl-3.0
|
| 5 |
+
library_name: ultralytics
|
| 6 |
+
pipeline_tag: image-segmentation
|
| 7 |
+
datasets:
|
| 8 |
+
- openpecha/OCR-Tibetan_line_segmentation_coordinate_annotation
|
| 9 |
+
tags:
|
| 10 |
+
- tibetan
|
| 11 |
+
- document-ai
|
| 12 |
+
- line-segmentation
|
| 13 |
+
- instance-segmentation
|
| 14 |
+
- yolo11
|
| 15 |
+
- ultralytics
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# PechaBridgeLineSegmentation
|
| 19 |
+
|
| 20 |
+
YOLO11n instance-segmentation model for detecting individual Tibetan text
|
| 21 |
+
lines on traditional pecha page scans. The model is the line-layout stage used
|
| 22 |
+
by [PechaBridge](https://github.com/CodexAITeam/PechaBridge) before OCR.
|
| 23 |
+
|
| 24 |
+
> **Important:** The supported PechaBridge inference pipeline applies the
|
| 25 |
+
> `gray` preprocessing mode (minimum RGB channel, no binarization) before YOLO
|
| 26 |
+
> inference. Raw Ultralytics inference can produce different results.
|
| 27 |
+
|
| 28 |
+
## Recommended usage — PechaBridge CLI
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
git clone https://github.com/CodexAITeam/PechaBridge.git
|
| 32 |
+
cd PechaBridge
|
| 33 |
+
pip install -r requirements.txt
|
| 34 |
+
|
| 35 |
+
# Downloads this model and the PechaBridge OCR model.
|
| 36 |
+
python cli.py download-models
|
| 37 |
+
|
| 38 |
+
python cli.py batch-ocr \
|
| 39 |
+
--input-dir /path/to/pecha/pages \
|
| 40 |
+
--ocr-model models/ocr/PechaBridgeOCR \
|
| 41 |
+
--line-model models/line_segmentation/PechaBridgeLineSegmentation.pt \
|
| 42 |
+
--layout-engine yolo_line \
|
| 43 |
+
--line-preprocess gray \
|
| 44 |
+
--ocr-engine donut
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Python usage
|
| 48 |
+
|
| 49 |
+
```python
|
| 50 |
+
from pathlib import Path
|
| 51 |
+
|
| 52 |
+
from huggingface_hub import snapshot_download
|
| 53 |
+
from PIL import Image
|
| 54 |
+
from ultralytics import YOLO
|
| 55 |
+
|
| 56 |
+
from pechabridge.ocr.line_segmentation import (
|
| 57 |
+
apply_line_segmentation_preprocess,
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
model_dir = Path(snapshot_download(
|
| 61 |
+
"TibetanCodexAITeam/PechaBridgeLineSegmentation"
|
| 62 |
+
))
|
| 63 |
+
weights = next(model_dir.glob("*.pt"))
|
| 64 |
+
model = YOLO(str(weights))
|
| 65 |
+
|
| 66 |
+
image = Image.open("page.jpg").convert("RGB")
|
| 67 |
+
prepared = apply_line_segmentation_preprocess(image, pipeline="gray")
|
| 68 |
+
results = model.predict(
|
| 69 |
+
source=prepared,
|
| 70 |
+
imgsz=1280,
|
| 71 |
+
conf=0.25,
|
| 72 |
+
verbose=False,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
for result in results:
|
| 76 |
+
print(result.boxes.xyxy) # line bounding boxes
|
| 77 |
+
print(result.masks.xy) # line polygons
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
## Model details
|
| 81 |
+
|
| 82 |
+
- **Architecture:** Ultralytics YOLO11n segmentation
|
| 83 |
+
- **Task:** single-class instance segmentation
|
| 84 |
+
- **Class:** `line`
|
| 85 |
+
- **Weights:** `yolo_line_seg.pt` (about 6.0 MB)
|
| 86 |
+
- **Recommended input size:** `1280`
|
| 87 |
+
- **Recommended confidence threshold:** `0.25`
|
| 88 |
+
- **Recommended preprocessing:** PechaBridge `gray`
|
| 89 |
+
- **Ultralytics version used for the exported checkpoint:** `8.4.14`
|
| 90 |
+
|
| 91 |
+
## Training data
|
| 92 |
+
|
| 93 |
+
The training corpus was derived from
|
| 94 |
+
[`openpecha/OCR-Tibetan_line_segmentation_coordinate_annotation`](https://huggingface.co/datasets/openpecha/OCR-Tibetan_line_segmentation_coordinate_annotation),
|
| 95 |
+
converted to YOLO polygons, padded, filtered, and split locally:
|
| 96 |
+
|
| 97 |
+
| Split | Images | Label files |
|
| 98 |
+
|---|---:|---:|
|
| 99 |
+
| Train | 3,487 | 3,487 |
|
| 100 |
+
| Validation | 519 | 519 |
|
| 101 |
+
| Test | 503 | 503 |
|
| 102 |
+
|
| 103 |
+
## Validation results
|
| 104 |
+
|
| 105 |
+
Metrics stored in the released checkpoint:
|
| 106 |
+
|
| 107 |
+
| Output | Precision | Recall | mAP50 | mAP50–95 |
|
| 108 |
+
|---|---:|---:|---:|---:|
|
| 109 |
+
| Bounding boxes | 0.97736 | 0.96768 | 0.99138 | 0.61298 |
|
| 110 |
+
| Segmentation masks | 0.90993 | 0.90055 | 0.89697 | 0.41885 |
|
| 111 |
+
|
| 112 |
+
These numbers describe the local validation split and should not be treated as
|
| 113 |
+
an independent cross-collection benchmark.
|
| 114 |
+
|
| 115 |
+
## Intended use and limitations
|
| 116 |
+
|
| 117 |
+
- Intended for locating horizontal Tibetan text lines in traditional pecha scans.
|
| 118 |
+
- Not an OCR model; detected line crops must be passed to a text recognizer.
|
| 119 |
+
- Performance may degrade on modern book layouts, handwriting, vertical text,
|
| 120 |
+
heavy page curvature, severe blur, unusual ornaments, or unseen collections.
|
| 121 |
+
- Closely spaced or touching lines may be merged; damaged lines may be fragmented.
|
| 122 |
+
- Predictions should be reviewed before scholarly or archival publication.
|
| 123 |
+
|
| 124 |
+
## License
|
| 125 |
+
|
| 126 |
+
AGPL-3.0. The checkpoint was trained with Ultralytics YOLO, whose open-source
|
| 127 |
+
software and trained model weights are distributed under AGPL-3.0 by default.
|
| 128 |
+
Commercial or closed-source use may require an Ultralytics Enterprise License.
|
| 129 |
+
|