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 custom recognition model
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>>> # custom crop and page orientation predictors
20>>> page_orientation_model = from_hub("madskills/mobilenet_v3_small_page_orientation_arabic")
21>>> crop_orientation_model = from_hub("madskills/mobilenet_v3_small_crop_orientation_arabic")
22
23# set the custom orientation predictors
24>>> predictor.crop_orientation_predictor = crop_orientation_predictor(
25>>> pretrained=False, arch=crop_orientation_model
26>>> )
27>>> predictor.page_orientation_predictor = page_orientation_predictor(
28>>> pretrained=False, arch=page_orientation_model
29>>> )
30
31>>> # Get your predictions
32>>> res = predictor(img)