Repository navigation
Lazy-load table recognition models to speed up startup and fix oneDNN crash - #270
Open
Jammy123-prog wants to merge 1 commit into
Open
Jammy123-prog wants to merge 1 commit into
Jammy123-prog wants to merge 1 commit into
Conversation
Startup currently builds the full PP-StructureV3 pipeline unconditionally. That loads ~14 bundled models (~1.1 GB) before the main window appears, adding several minutes to launch on machines without a warm model cache, even for users who only annotate plain text and never touch the table-recognition feature. The startup warm-up run of table_ocr.predict() has the same cost. With PaddleX >= 3.7 there is a second problem: the HPI auto-tuner may select the oneDNN backend for the table models, which aborts with "NotImplementedError: ConvertPirAttribute2RuntimeAttribute not support [pir::ArrayAttribute<pir::DoubleAttribute>]" on Paddle 3.3.1. Changes: - Initialize self.table_ocr = None and build the pipeline lazily in a new _get_table_ocr() helper, used by TableRecognition(). - Drop the eager table warm-up call on startup (the text OCR warm-up is kept). - Pass enable_mkldnn=False and enable_hpi=False when constructing PPStructureV3 to keep a stable, working backend. - The language-switch rebuild path now just resets self.table_ocr so the pipeline is rebuilt on demand with the new language. Result: startup only loads the det/rec models; table recognition still works, loading its models on first use.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MainWindow.__init__builds the fullPPStructureV3pipeline unconditionally. That loads ~14 bundled models (~1.1 GB: PP-DocLayout-L, SLANeXt/SLANet, RT-DETR-L cell detectors, etc.) before the main window appears — on a machine without a warm model cache this adds several minutes to launch, even for users who only annotate plain text and never use table recognition. The eager warm-up calltable_ocr.predict("./data/paddle.png")has the same cost.Observed with paddlepaddle-gpu 3.3.1 + paddlex 3.7.2 on Windows 11 (RTX 1000 Ada, CUDA 12.6).
Fix
self.table_ocr = Noneand construct the pipeline lazily in a new_get_table_ocr()helper, called fromTableRecognition(). Table features work exactly as before — models simply load on first use.enable_mkldnn=False, enable_hpi=Falsewhen constructingPPStructureV3so a stable, working backend is used (mirrors what PPOCRLabel already does for itsPaddleOCRinstance).self.table_ocr = None; the pipeline is rebuilt on demand with the new language.Result
Startup now only loads det/rec models (
Creating modellines drop from 16 to 2 in a typical session); resident GPU memory drops accordingly, which also helps low-VRAM laptops. Table recognition remains fully functional, loading its models on first use (~1 min one-time cost, then cached).Verified: offscreen launch test with custom
--det_model_dir/--rec_model_dirmodels loads only 2 models and runs clean; table recognition path works after lazy init.中文说明
问题:① 启动时无条件构建
PPStructureV3全套表格识别管线(约 14 个模型、1.1GB),纯文本标注场景也要多等数分钟;② PaddleX ≥ 3.7 的 HPI 自动调优可能为表格模型选中 oneDNN 后端,启动即抛NotImplementedError崩溃。修复:表格管线改为首次使用时懒加载(新增
_get_table_ocr());删除启动阶段的表格推理预热;构造时显式enable_mkldnn=False, enable_hpi=False(与 PPOCRLabel 对PaddleOCR的处理一致);切换语言处仅置空table_ocr,按需重建。启动只加载检测/识别两个模型,表格标注功能不受影响。已在 Windows 11 + paddlepaddle-gpu 3.3.1 环境验证。