mirror of
https://github.com/PaddlePaddle/PaddleOCR.git
synced 2026-08-29 04:12:51 +08:00
main
12 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
74bdc41608 |
feat: add multi-language API SDK (Python/Go/TypeScript) (#18049)
* feat: add multi-language API SDK for PaddleOCR async API Add Python/Go/TypeScript SDKs that wrap the PaddleOCR async job API (submit → poll → fetch result) into simple blocking interfaces. Python SDK: - Integrated into paddleocr/_api_client/ as internal subpackage - APIClient (sync) + AsyncAPIClient (asyncio) dual interfaces - CLI subcommand: paddleocr api --model_type ocr/doc_parsing - Supports PP-OCRv5, PP-StructureV3, PaddleOCR-VL, PaddleOCR-VL-1.5 Go SDK (api_sdk/go/): - Zero dependencies (stdlib only) - Functional options pattern + context.Context cancellation - Operation object with Wait(ctx)/Poll(ctx) methods TypeScript SDK (api_sdk/typescript/): - Zero dependencies (native fetch, Node>=18) - AbortSignal cancellation support - ESM + CJS dual output All SDKs share: - Exponential backoff polling (3s initial, 1.5x, 15s max, configurable timeout) - Typed error hierarchy (Auth/API/JobFailed/Timeout/Network/FileNotFound) - URL and local file upload support - Convenience methods + manual control (submit/wait/poll) interfaces * fix: address PR review feedback - Rename PaddleOCRError to PaddleOCRAPIError across all three SDKs - Replace custom FileNotFoundError with Python builtin in Python SDK - Expand OCROptions/DocParsingOptions with all API parameters (Python/Go/TS) - CLI: use Model enum values instead of hardcoded strings - CLI: allow --model for both ocr and doc_parsing tasks - Update license header year to 2026 - Simplify TypeScript defaultPayload to empty object * fix: harden multi-language API SDK Co-authored-by: Cursor <cursoragent@cursor.com> * fix(sdk): jsonl fetch without auth, poll timeout, abort parity Co-authored-by: Cursor <cursoragent@cursor.com> * feat: harden PaddleOCR official API SDK Align Python, TypeScript, and Go SDKs around typed jobs, model-aware document parsing, request/poll timeouts, strict errors, resource saving, and integrated release docs for the PaddleOCR official API. Co-authored-by: Cursor <cursoragent@cursor.com> * feat: complete API SDK remediation and default doc parsing to PaddleOCR-VL-1.5 Consolidate SDK hardening, docs, tests, and cross-language default model behavior for document parsing. Co-authored-by: Cursor <cursoragent@cursor.com> * Fix bugs * Fix bugs and optimize sdks * Fix bugs * Fix bugs * Update skills * Fix bugs * Update docs * Fix docs * Fix doc * Fix --------- Co-authored-by: Bobholamovic <bob1998425@hotmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> |
||
|
|
0715ed937d |
feat: support to convert office document (docx/xlsx/pptx) to Markdown (#17884)
* feat: integrate Any2MD as paddleocr._doc2md for office document conversion Add `paddleocr/_doc2md/` subpackage that converts .docx/.xlsx/.pptx to Markdown directly, without requiring OCR. Features include heading detection, list/table handling, merged cells, and image extraction. - New `paddleocr/_doc2md/` subpackage adapted from Any2MD source - CLI subcommand `paddleocr doc2md -i <file> [-o <output>] [--formats]` - Python API: `doc2md_convert`, `doc2md_convert_bytes`, `doc2md_supported_formats` - Optional dependency group `doc2md` in pyproject.toml Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: clean up doc2md integration based on code review - Fix eager import: doc2md_convert/convert_bytes/supported_formats are now lazy wrappers so importing paddleocr does not load docx/pptx/xlsx deps - Translate remaining Chinese strings in _cli.py (docstring, help text, log messages) to English - Add missing --input validation in doc2md CLI (clear error instead of crash) - Remove duplicate `import time` and inline `from pathlib import Path` from _execute_doc2md - Extract _merge_runs() helper to eliminate duplicate run-merging logic shared by _runs_to_markdown and _runs_to_html in converters/docx.py - Change output encoding from utf-8-sig to utf-8 (consistent with the rest of PaddleOCR) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: replace custom exception classes with Python built-ins in _doc2md PaddleOCR convention uses Python built-in exceptions directly rather than defining custom exception hierarchies. Align _doc2md with this convention: - Remove exceptions.py and the Any2MDError / UnsupportedFormatError / ConversionError custom classes - UnsupportedFormatError -> ValueError (invalid input argument) - ConversionError -> RuntimeError (runtime failure, matches how DependencyError is wrapped in _pipelines/base.py) - Update all raise/except/import sites across registry.py, core.py, and converters/docx.py, pptx.py, xlsx.py Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: remove convert_bytes from _doc2md convert_bytes has no callers in the current codebase (CLI and Python API both use convert()). Internally it wrote to a temp file anyway since the underlying libraries only accept file paths, so it provided no real benefit. - Remove convert_bytes() from core.py - Remove BaseConverter.convert_bytes() from base.py - Remove doc2md_convert_bytes from paddleocr.__init__ and __all__ - Remove from _doc2md/__init__.py exports Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: remove .xls support from XlsxConverter openpyxl only supports .xlsx (OOXML format), not .xls (legacy BIFF binary format). Registering .xls caused confusing openpyxl internal errors instead of a clear "unsupported format" message. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: narrow exception catch to ImportError in converter __init__ Catching bare Exception silently hides bugs (SyntaxError, NameError, etc.) in converter modules. Only ImportError (and its subclass ModuleNotFoundError) should be suppressed, as the intent is to handle missing optional dependencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * chore: add Apache 2.0 license header to all _doc2md modules Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add hyperlink support to docx/xlsx/pptx converters - docx: add _escape_md_url, _parse_field_hyperlinks (w:fldChar state machine), _iter_paragraph_items; extend _merge_runs/_runs_to_markdown/_runs_to_html to carry URL and emit [text](url) / <a href> accordingly - xlsx: wrap cell text in <a href> when cell.hyperlink.target is present - pptx: add _escape_md_url; iterate runs in TextFrame and table cells to emit [text](url) in lists and <a href> in HTML tables Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add underline and strikethrough support to docx/pptx/xlsx converters - docx: extend run tuple from 4-tuple to 6-tuple (bold, italic, underline, strikethrough, text, url); render underline as <u> and strikethrough as ~~ in Markdown, <u>/<del> in HTML tables; suppress hyperlink underline to avoid Word's default Hyperlink style false-positives - pptx: add bold/italic/underline/strikethrough rendering in TextFrame and table cells; read strike via XML (a:rPr/@a:strike) since python-pptx Font has no .strike attribute - xlsx: wrap cell text with <b>/<i>/<u>/<del> from cell.font before hyperlink Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add OMML math formula (LaTeX) support to docx and pptx converters - Add paddleocr/_doc2md/math/ module with OMML→LaTeX converter (omml.py, latex_dict.py) - docx.py: detect and convert m:oMath elements to inline ($...$) and display ($$...$$) LaTeX - pptx.py: detect and convert a14:m/m:oMath elements in text frames, tables, and mc:AlternateContent blocks - pyproject.toml: add pylatexenc>=2.10,<3 to doc2md optional dependencies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add TOC rendering with multi-generation anchor support to docx converter - Extract TOC paragraphs (styles "TOC 1"–"TOC 9", "table of figures") into a buffered list and render them as a Markdown nested list before the first non-TOC paragraph. - TOC entry links are extracted via w:hyperlink[@w:anchor] or PAGEREF field instructions (_extract_toc_anchor). - Body headings emit <a id="..."> tags for ALL _Toc bookmarks found, not just the first. This handles documents where multiple TOC sections (main, figure, table) were updated at different times and therefore reference different generations of _Toc bookmarks on the same heading. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add textbox extraction to docx converter and expose converter kwargs via CLI - docx: extract text box content (mc:AlternateContent/wps:txbx) as blockquotes, controlled by extract_textboxes kwarg (default True) - cli: add --no-textboxes, --sheet-name, --max-rows flags to doc2md subcommand, transparently forwarded to the underlying converter Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add header/footer extraction to docx converter Extract page headers and footers from all document sections, deduplicate content, filter page-number-only text, and output headers at document top and footers after a horizontal rule. Supports extract_headers_footers=False kwarg and --no-headers-footers CLI flag to skip extraction. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: preserve pure-whitespace underline runs as fill-in lines in docx converter Pure whitespace text with underline formatting (common Word fill-in line pattern) was silently dropped because inner.strip() == "" caused the underline wrapper to be skipped. Now renders as <u> ... </u> using NBSP to preserve visual width in Markdown renderers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use tblHeader XML flag to determine table header rows instead of hardcoding first row as <th> Single-row tables (e.g. fixed-content rows) were incorrectly rendered as <th> causing unintended bold styling. Now checks w:tblHeader element first; falls back to first-row heuristic only for multi-row tables. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: inherit paragraph style bold/italic/underline when run-level format is unset Add _effective_bold/italic/underline() helpers that resolve the effective format by walking the inheritance chain: run-level > character style > paragraph style. Replace all bool(run.bold/italic/underline) call sites with these helpers. Fixes Caption-style paragraphs (and other styled paragraphs) whose runs carry no direct formatting but inherit bold/italic/underline from the paragraph style — previously rendered as plain text. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: preserve pure-whitespace underline runs as fill-in lines in pptx converter Same fix as commit 7255b2e for docx: pure whitespace text with underline format was stripped to empty string and discarded. Now replaced with NBSP characters wrapped in <u> to preserve fill-in line width. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: handle soft line breaks (<w:br/>) in docx and pptx converters Split runs containing \n (from Shift+Enter / <w:br/>) into per-line items with <br> separators, so CommonMark does not collapse them into continuous text. Also fixes cross-line bold/italic markers that would otherwise be invalid Markdown. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * style: add newline after <br> in soft line breaks for Markdown readability 普通段落中每个 <br> 标签后附加真实换行符,让 Markdown 源码多行可读; heading 和列表项路径回退为 <br>(无 \n),避免 CommonMark 解析异常。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: map Word Title/Subtitle styles to H1/H2 in docx converter Word built-in "Title" and "Subtitle" paragraph styles were not recognized as headings, causing documents with these styles to lose their top-level heading structure. Map Title → H1 and Subtitle → H2 alongside the existing Heading N detection logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add superscript/subscript support in xlsx converter Read cell.font.vertAlign via openpyxl and wrap cell text with <sup> or <sub> tags when the value is 'superscript' or 'subscript'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: use val axis title as series header fallback in chart tables When a chart series has no <c:tx> element, the series column header was rendered as empty <th></th>. Now falls back to the value axis title (e.g. "下载量") so the header carries semantic meaning. Also omits <thead> entirely when neither axis titles nor series names provide any header content, avoiding rows of empty <th> tags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add superscript/subscript support in pptx converter Detect DrawingML baseline attribute on <a:rPr>: positive value → <sup>, negative value → <sub>. Applies to both regular slide text and table cell content. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: fix pptx chart type names, date axis conversion, and series header fallback - Fix _CHART_TYPE_NAMES dict to use actual XL_CHART_TYPE enum values (e.g. 51→Column Chart, -4120→Doughnut Chart instead of wrong mappings) - Convert Excel date serials to YYYY-MM-DD when chart has a dateAx element - Use valAx title as series name fallback when series.tx is None - Replace GFM Markdown table output with HTML <table> (per CLAUDE.md §6) - Rename _chart_to_md → _chart_to_html Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: remove redundant chart type label before HTML table in pptx chart output Chart title is already conveyed via <caption>; the "**Column Chart**" label is a leftover from the old GFM Markdown table approach and has no place in an HTML <table> output. Aligns with docx converter behavior. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: remove injected Slide N metadata headers from pptx output Title shapes are now processed through the normal shape pipeline instead of being extracted and rendered as forced H2 headings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat: add xlsx drawing-layer math formula extraction and rename extract_textboxes to extract_drawings - xlsx: parse drawing XML via zipfile to extract OMML math formulas, output as $$ ... $$ blocks after the table (extract_drawings=True by default) - Rename extract_textboxes → extract_drawings across docx.py, xlsx.py, _cli.py to better reflect the shared semantics (textboxes in docx, drawing layer in xlsx) - CLI: --no-textboxes → --no-drawings Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: fix duplicate math formula output caused by incorrect oMathPara dedup When structure is a14:m → oMathPara → oMath, the oMathPara loop was checking oMath's parent (oMathPara) instead of oMathPara's parent (a14:m), so the formula was emitted twice. Fix: skip oMathPara if its own parent is a14:m. Affects both pptx.py and xlsx.py _extract_math_from_paragraph. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: deduplicate OMML math helpers across docx/pptx/xlsx converters Extract shared DrawingML math functions (convert_omath, paragraph_has_math, extract_math_from_paragraph) into math/__init__.py and replace duplicates in pptx.py/xlsx.py with imports. In docx.py, merge _paragraph_math_to_markdown and _paragraph_math_to_html via shared _iter_math_paragraph_parts. Net -98 lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: promote constants/closures to module level and remove dead imports - docx.py: extract _WPD/_A/_R as module-level constants (eliminate per-call local defs in _extract_images_from_paragraph and _extract_chart_tables); remove duplicate WP local vars in _build_numbering_map/_get_list_info, use module-level _W instead; move Run/Hyperlink imports above loop in _iter_math_paragraph_parts - pptx.py: promote _A/_MC/_C namespaces and _CHART_TYPE_NAMES dict to module level; extract _classify_part and _format_run_segment as module-level functions (were per-call closures); move Picture/MSO_SHAPE_TYPE imports to convert_file; remove unused convert_omath and Emu imports - xlsx.py: remove unused convert_omath import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * refactor: replace Chinese comments with English in docx and xlsx converters Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add doc2md user guide (Chinese) Add docs/version3.x/pipeline_usage/doc2md.md covering: - Feature overview with capability matrix for docx/xlsx/pptx - Quick start: installation, CLI usage, Python API - Per-format supported features - FAQ section Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs: add doc2md user guide (English) Add docs/version3.x/pipeline_usage/doc2md.en.md, the English counterpart of doc2md.md, covering the same structure: feature overview, quick start (CLI + Python API), per-format supported features, and FAQ. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * doc: move * docs: add save_to_word() method to PP-StructureV3 and PaddleOCR-VL pipeline docs Add save_to_word() code example and method reference table entry to both Chinese and English versions of PP-StructureV3 and PaddleOCR-VL pipeline usage tutorials, syncing with PaddleX PR #5092. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|
|
e3b42d5cd4 |
[Feat] Support building SM120 images (#16919)
* Support building SM120 images * Set VLM batch size to 4096 * Support Switching to fastdeploy backend * Update dockerfiles * Fix config file * Support DCU and XPU * Remove unused file * Fix bugs * Support install genai fastdeploy server deps * Bump FD version to 2.3.0 * Fix pipeline configs * Fix dockerfile for DCU * Add DCU and XPU compose files * Add XPU compose files |
||
|
|
daaa599597 |
[Feat] Support PaddleOCR-VL (#16602)
* Add PaddleOCR-VL * Support setting max_concurrency * Update docs * Support new predict params * Update pipeline and demo name * Fix bugs * Fix bugs * Fix errors in documentation * Remove unit tests temporarily * Fix bugs and update docs * Add algorithm docs * Update layout analysis and paddleocr-vl docs * Fix doc --------- Co-authored-by: cuicheng01 <45199522+cuicheng01@users.noreply.github.com> |
||
|
|
a5b172e3d9 | Add chart parsing module (#16111) | ||
|
|
de0ecd466f |
[Feat] Add PP-DocTranslate and update docs (#15890)
* Add PP-DocTranslate and update docs * Fix docs * Add English doc * Fix ut |
||
|
|
4a3f01e129 |
[WIP][Feat] Accommodate PaddleX MKL-DNN new behavior (#15471)
* Accommodate PaddleX MKL-DNN new behavior * Bump paddlex version * Use stderr |
||
|
|
6cbf707536 |
[Fix] Set subcommand as required (#15281)
* Set subcommand as required * Update |
||
|
|
eac5578fe2 |
[Docs] Add upgrade notes and fix docs (#15198)
* Unify refs * Fix extra newline * Update mkldnn_blocklists * Add upgrade notes * Fix docs * Add English upgrade notes * Bump paddlex to 3.0.0 * Update upgrade notes |
||
|
|
b25dcaae0e |
Add deployment docs and enhance CLI (#15117)
* Add serving and hpi docs * Optimize CLI logging info * Update interface * Add on-device deployment and onnx model conversion docs * Enhance CLI * _gen->_iter * Fix CLI help message * Update table_recognition_v2 and PP-StructureV3 interfaces * Update installation doc * Update interface * Update interface * Add logging doc * Update default values --------- Co-authored-by: cuicheng01 <45199522+cuicheng01@users.noreply.github.com> |
||
|
|
a4fdd4dbdb | Add dep installation CLI command (#15103) | ||
|
|
3d03ca5500 |
[Breaking][Feat] New PaddleOCR inference package (#15046)
* Init new paddleocr * Remove unused dependency * Fix typos * Fix * Add doc understanding modules * Fix package finding * Normalize name * Fix setting bugs * Fix setting bug * Support single model inference * Add PP-ChatOCRv4-doc * Add pp_chatocrv4_doc tests * Enable MKL-DNN when available * add seal_text_detection modules * add layout_detection and table_cells_detection modules * add testing scripts * Fix desc * add text_image_unwarping and table_structure_recognition modules * add formula_recognition and doc_vlm modules * update formula_recognition default_model_name * add MKLDNN_BLOCKLIST * update MKLDNN log * add seal rec pipeline * fix sth * fix sth * add doc preprocessor pipeline * fix sth * add doc understanding * add table_rec_v2, ppstructurev3, formula_rec pipelines * move test files * forward kwargs to pipeline.predict * clean test files * Add missing kwargs * Fix typo * Fix typo * rerun CI * update mkldnn BLOCKLIST * update * update warning message * fix cli args * update PIPELINE_MKLDNN_BLOCKLIST * update of workflow * skip resource_intensive tests * update config * skip ppdocbee test_predict_params --------- Co-authored-by: zhangyue66 <zhangyue66@baidu.com> Co-authored-by: zhangzelun <zhangzelun@baidu.com> |