ai-forever/school_notebooks_RU
Updated • 319 • 18
Handwritten text detection model for Russian notebook images.
This model is intended to find text regions (words / short text fragments) in handwritten notebook images so you can crop them and pass the crops to an OCR model (e.g. kotmayyaka/hwr_text_ocr_rus).
It is not a full OCR pipeline by itself.
hwr_text_detection_rus.pthhwr_detection.py — detector wrapper class (load + preprocess + postprocess)inference_detection.py — CLI examplepip install torch torchvision pillow opencv-python
python inference_detection.py \
--image /path/to/page_or_crop.jpg \
--checkpoint hwr_text_detection_rus.pth \
--out detections.json
from PIL import Image
from hwr_detection import HWRTextDetector
detector = HWRTextDetector(
checkpoint_path="hwr_text_detection_rus.pth",
device="cpu",
score_thresh=0.1,
config="COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml",
num_classes=1
)
img_path = "sample.jpg"
img = Image.open(img_path).convert("RGB")
preds = detector.predict_polygons(img)
detector.save_custom_json(preds, img_path, "preds.json")
You can then crop the regions and send them to an OCR model.
Metrics reported in the model card header were obtained on an internal mixed validation split based on: