(args)
| 206 | |
| 207 | |
| 208 | def _execute_api(args): |
| 209 | kwargs = {} |
| 210 | if args.token: |
| 211 | kwargs["token"] = args.token |
| 212 | if args.base_url: |
| 213 | kwargs["base_url"] = args.base_url |
| 214 | kwargs["request_timeout"] = args.request_timeout |
| 215 | kwargs["poll_timeout"] = args.poll_timeout |
| 216 | if args.client_platform: |
| 217 | kwargs["client_platform"] = args.client_platform |
| 218 | |
| 219 | try: |
| 220 | client = PaddleOCRClient(**kwargs) |
| 221 | except Exception as e: |
| 222 | print(f"Error: {e}", file=sys.stderr) |
| 223 | sys.exit(1) |
| 224 | |
| 225 | try: |
| 226 | model = _resolve_model(args.model) if args.model else None |
| 227 | |
| 228 | if args.model_type == "ocr": |
| 229 | if model is not None and not is_ocr_model(model): |
| 230 | print( |
| 231 | f"Error: OCR task does not support {model.value}.", |
| 232 | file=sys.stderr, |
| 233 | ) |
| 234 | sys.exit(2) |
| 235 | options = OCROptions( |
| 236 | use_doc_orientation_classify=args.use_doc_orientation_classify, |
| 237 | use_doc_unwarping=args.use_doc_unwarping, |
| 238 | use_textline_orientation=args.use_textline_orientation, |
| 239 | text_det_limit_side_len=args.text_det_limit_side_len, |
| 240 | text_det_limit_type=args.text_det_limit_type, |
| 241 | text_rec_score_thresh=args.text_rec_score_thresh, |
| 242 | visualize=args.visualize, |
| 243 | ) |
| 244 | result = client.ocr( |
| 245 | file_url=args.file_url, |
| 246 | file_path=args.file_path, |
| 247 | options=options, |
| 248 | page_ranges=args.page_ranges, |
| 249 | batch_id=args.batch_id, |
| 250 | model=model or Model.PP_OCRV6, |
| 251 | ) |
| 252 | output = _ocr_result_to_dict(result) |
| 253 | save_resources = client.save_ocr_result_resources |
| 254 | else: |
| 255 | if model is None: |
| 256 | model = Model.PADDLE_OCR_VL_16 |
| 257 | if is_vl_model(model): |
| 258 | options = PaddleOCRVLOptions( |
| 259 | use_doc_orientation_classify=args.use_doc_orientation_classify, |
| 260 | use_doc_unwarping=args.use_doc_unwarping, |
| 261 | use_chart_recognition=args.use_chart_recognition, |
| 262 | use_seal_recognition=args.use_seal_recognition, |
| 263 | use_layout_detection=args.use_layout_detection, |
| 264 | prettify_markdown=args.prettify_markdown, |
| 265 | visualize=args.visualize, |
nothing calls this directly
no test coverage detected