Views
No views yet
Important: This checkpoint expects PechaBridge'sgraypreprocessing followed by a fixed256×1024resize. Thegraypipeline uses the minimum RGB channel as grayscale and does not binarize the image. Use the PechaBridge CLI for the supported end-to-end path; raw image input or a genericAutoTokenizerpath will not reproduce the training pipeline.
1git clone https://github.com/CodexAITeam/PechaBridge.git && cd PechaBridge
2pip install -r requirements.txt
3python cli.py download-models
4
5python cli.py batch-ocr \
6 --ocr-model models/ocr/PechaBridgeOCR \
7 --line-model models/line_segmentation/PechaBridgeLineSegmentation.pt \
8 --layout-engine yolo_line \
9 --ocr-engine donut \
10 --input-dir /path/to/pecha/images.txt transcript and an *_overlay.jpg preview.AutoTokenizer.1from pathlib import Path
2import torch
3from huggingface_hub import snapshot_download
4from PIL import Image
5from transformers import AutoImageProcessor, VisionEncoderDecoderModel
6from pechabridge.ocr.preprocess_bdrc import BDRCPreprocessConfig, preprocess_image_bdrc
7from pechabridge.ocr.sentencepiece_tokenizer_adapter import load_sentencepiece_tokenizer
8
9model_dir = Path(snapshot_download("TibetanCodexAITeam/PechaBridgeOCR"))
10model = VisionEncoderDecoderModel.from_pretrained(model_dir).eval()
11image_processor = AutoImageProcessor.from_pretrained(model_dir, use_fast=False)
12tokenizer = load_sentencepiece_tokenizer(model_dir)
13image = Image.open('line_crop.png').convert('RGB')
14cfg = BDRCPreprocessConfig.vit_defaults()
15cfg = BDRCPreprocessConfig.from_dict({
16 **cfg.to_dict(), 'binarize': False, 'gray_mode': 'min_rgb',
17})
18prepared = preprocess_image_bdrc(image=image, config=cfg).convert('RGB')
19pixel_values = image_processor(images=prepared, return_tensors='pt').pixel_values
20with torch.inference_mode():
21 generated_ids = model.generate(pixel_values)
22text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
23print(text)checkpoint-184000 (step 184000)gray256×1024 resize, RGB tensor normalized with mean/std 0.5repro/| Checkpoint | Internal validation CER | Valid samples |
|---|---|---|
checkpoint-184000 | 0.5751% | 241 |
| Source dataset | Samples | Mean CER |
|---|---|---|
| OCR-Norbuketaka | 2,350 | 0.43% |
| OCR-Google_Books | 812 | 1.59% |
| OCR-Lhasakanjur | 118 | 1.92% |
| OCR-Drutsa | 14 | 3.54% |
| OCR-Betsug | 12 | 3.86% |