Views
No views yet
1>>> from doctr.io import DocumentFile
2>>> from doctr.models import ocr_predictor, from_hub
3
4>>> img = DocumentFile.from_images(['<image_path>'])
5
6>>> # Load your models from the hub
7>>> reco_model = from_hub("madskills/parseq_arabic_v1")
8
9>>> # Load custom detection model for best performance
10>>> det_model = from_hub("madskills/fast_base_arabic_v1")
11
12>>> # Pass it to the predictor
13>>> # If your model is a recognition model:
14>>> predictor = ocr_predictor(det_arch=det_model,
15>>> reco_arch=reco_model,
16>>> pretrained=True
17>>> )
18
19>>> # optional if your documents are not well oriented
20>>> # custom crop and page orientation predictors
21>>> page_orientation_model = from_hub("madskills/mobilenet_v3_small_page_orientation_arabic")
22>>> crop_orientation_model = from_hub("madskills/mobilenet_v3_small_crop_orientation_arabic")
23
24# set the custom orientation predictors
25>>> predictor.crop_orientation_predictor = crop_orientation_predictor(
26>>> pretrained=False, arch=crop_orientation_model
27>>> )
28>>> predictor.page_orientation_predictor = page_orientation_predictor(
29>>> pretrained=False, arch=page_orientation_model
30>>> )
31
32>>> # Get your predictions
33>>> res = predictor(img)