Views
No views yet
Important: The supported PechaBridge inference pipeline applies thegraypreprocessing mode (minimum RGB channel, no binarization) before YOLO inference. Raw Ultralytics inference can produce different results.
1git clone https://github.com/CodexAITeam/PechaBridge.git
2cd PechaBridge
3pip install -r requirements.txt
4
5# Downloads this model and the PechaBridge OCR model.
6python cli.py download-models
7
8python cli.py batch-ocr \
9 --input-dir /path/to/pecha/pages \
10 --ocr-model models/ocr/PechaBridgeOCR \
11 --line-model models/line_segmentation/PechaBridgeLineSegmentation.pt \
12 --layout-engine yolo_line \
13 --line-preprocess gray \
14 --ocr-engine donut1from pathlib import Path
2
3from huggingface_hub import snapshot_download
4from PIL import Image
5from ultralytics import YOLO
6
7from pechabridge.ocr.line_segmentation import (
8 apply_line_segmentation_preprocess,
9)
10
11model_dir = Path(snapshot_download(
12 "TibetanCodexAITeam/PechaBridgeLineSegmentation"
13))
14weights = next(model_dir.glob("*.pt"))
15model = YOLO(str(weights))
16
17image = Image.open("page.jpg").convert("RGB")
18prepared = apply_line_segmentation_preprocess(image, pipeline="gray")
19results = model.predict(
20 source=prepared,
21 imgsz=1280,
22 conf=0.25,
23 verbose=False,
24)
25
26for result in results:
27 print(result.boxes.xyxy) # line bounding boxes
28 print(result.masks.xy) # line polygonslineyolo_line_seg.pt (about 6.0 MB)12800.25gray8.4.14openpecha/OCR-Tibetan_line_segmentation_coordinate_annotation,
converted to YOLO polygons, padded, filtered, and split locally:| Split | Images | Label files |
|---|---|---|
| Train | 3,487 | 3,487 |
| Validation | 519 | 519 |
| Test | 503 | 503 |
| Output | Precision | Recall | mAP50 | mAP50–95 |
|---|---|---|---|---|
| Bounding boxes | 0.97736 | 0.96768 | 0.99138 | 0.61298 |
| Segmentation masks | 0.90993 | 0.90055 | 0.89697 | 0.41885 |