INNER CODE UNIT · Python
_build_predictor
mindee/doctr · doctr/cli/main.py:192
def _build_predictor(args: argparse.Namespace) -> Any:
"""Instantiate the OCR predictor matching the requested options
Args:
args: the parsed command-line arguments
Returns:
the predictor
"""
# Region masking is resolved by the layout model, so it has to be enabled along with `ignore_regions`
detect_layout = args.detect_layout or bool(args.ignore_regions)
if detect_layout and not args.detect_layout:
logger.info("--ignore_regions requires the layout model: layout detection has been enabled")
kwargs: dict[str, Any] = {
"det_arch": args.det_arch,
"reco_arch": args.reco_arch,
"pretrained": True,