YOLO Khmer Math and Text Line Detector (v5.0 - khmer_V3dectect)
State-of-the-art YOLOv8 model for detecting Khmer printed text lines and mathematical formulas across MoEYS textbooks and exam papers.
Highlights of the Model (v5.0 / khmer_V3dectect)
- 96.78% mAP@50: Peak performance across all versions.
- 81.96% mAP@50-95: High bounding box tightness and precision for text and formula cropping.
- 93.33% Recall: Captures complex stacked formulas, sub/superscripts, fractions, and Khmer diacritics.
- 94.89% Precision: Low false positives on empty document spaces or page margins.
- Lightweight and Fast: Compact model (~6.2 MB PyTorch
.pt, ~11.7 MB ONNX .onnx) optimized for edge and web execution.
Model Checkpoints and Download Links
Version Evolution and Benchmark
Quickstart Inference
Python (Ultralytics)
from ultralytics import YOLO
from huggingface_hub import hf_hub_download
# Download best model directly from Hugging Face
model_path = hf_hub_download(
repo_id="krotreaksmey/Yolo_Detect_khmer_math",
filename="best.pt"
)
# Load model
model = YOLO(model_path)
# Predict on full textbook or exam page
results = model.predict(
source="textbook_page.png",
conf=0.25,
iou=0.45,
imgsz=640
)
# Extract detected text/math lines
for r in results:
for box in r.boxes:
x1, y1, x2, y2 = box.xyxy[0].tolist()
conf = float(box.conf[0])
cls_id = int(box.cls[0])
print(f"Line detected at [{x1:.1f}, {y1:.1f}, {x2:.1f}, {y2:.1f}] (conf: {conf:.2f})")
ONNX Runtime (Python / WebAssembly / C++)
import onnxruntime as ort
import numpy as np
from PIL import Image
from huggingface_hub import hf_hub_download
onnx_path = hf_hub_download(
repo_id="krotreaksmey/Yolo_Detect_khmer_math",
filename="best.onnx"
)
session = ort.InferenceSession(onnx_path)
# Preprocess image with 640x640 letterboxing
im = Image.open("textbook_page.png").convert("RGB")
w, h = im.size
scale = min(640 / w, 640 / h)
nw, nh = int(w * scale), int(h * scale)
im_resized = im.resize((nw, nh), Image.Resampling.BILINEAR)
padded = Image.new("RGB", (640, 640), (114, 114, 114))
pad_x = (640 - nw) // 2
pad_y = (640 - nh) // 2
padded.paste(im_resized, (pad_x, pad_y))
input_arr = np.array(padded, dtype=np.float32) / 255.0
input_arr = np.transpose(input_arr, (2, 0, 1))[np.newaxis, ...]
outputs = session.run(["output0"], {"images": input_arr})
predictions = outputs[0] # shape: (1, 5, 8400)
Training Visualizations
Metric Progress and Loss Curves
Intended Use and Applications
- Khmer MoEYS Math and Science OCR: First-stage line segmentation before passing crops to PARSeq / TrOCR recognition models.
- Interactive Education and AI Vision Teacher: Automatic extraction and solving of math exercises from photo and PDF submissions.
- Document Digitization: Archiving Grade 1 to 12 national exams, curriculum books, and research documents.
Citation
@misc{yolo_khmer_math_v5,
title={YOLO Khmer Math and Text Line Detection Model (v5.0)},
author={krotreaksmey},
year={2026},
publisher={Hugging Face},
url={https://huggingface.co/krotreaksmey/Yolo_Detect_khmer_math}
}