PaddleDetection icon indicating copy to clipboard operation
PaddleDetection copied to clipboard

直接下载使用推理模型OK,下载预训练模型然后重新导出后不可用(没做训练)

Open colinlwz opened this issue 1 year ago • 5 comments

问题确认 Search before asking

  • [X] 我已经搜索过问题,但是没有找到解答。I have searched the question and found no related answer.

请提出你的问题 Please ask your question

直接使用推理模型:

1.下载版面CDLA推理模型 wget https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar tar xf picodet_lcnet_x1_0_fgd_layout_cdla_infer.tar

2.通过PaddleOCR使用CDLA推理模型进行pdf版面恢复 cd PaddleOCR/ppstructure/ python3 predict_system.py
--layout_model_dir=inference/picodet_lcnet_x1_0_fgd_layout_cdla_infer
--layout_dict_path=../ppocr/utils/dict/layout_dict/layout_cdla_dict.txt
--vis_font_path=../doc/fonts/simfang.ttf
--recovery=True
--det_model_dir=inference/ch_PP-OCRv3_det_infer
--rec_model_dir=inference/ch_PP-OCRv3_rec_infer
--table_model_dir=inference/ch_ppstructure_mobile_v2.0_SLANet_infer
--rec_char_dict_path=../ppocr/utils/ppocr_keys_v1.txt
--table_char_dict_path=../ppocr/utils/dict/table_structure_dict_ch.txt
--output=../output/
--image_dir=/home/aistudio/test/zx/testtable.pdf

3.运行结果:OK,成功转出word文档

下载版面CDLA预训练模型并重新导出推理模型:

1.下载CDLA预训练模型 wget https://paddleocr.bj.bcebos.com/ppstructure/models/layout/picodet_lcnet_x1_0_fgd_layout_cdla.pdparams

2.通过PaddleDetection直接将预训练模型导出成infer模型 cd PaddleDetection/ python3 tools/export_model.py
-c configs/picodet/legacy_model/application/layout_analysis/picodet_lcnet_x1_0_layout.yml
-o weights=/home/aistudio/PaddleDetection/pretrained_model/picodet_lcnet_x1_0_fgd_layout_cdla.pdparams
--output_dir=/home/aistudio/PaddleDetection/pretrained_model/

3.通过PaddleOCR使用CDLA推理模型进行pdf版面恢复 cd PaddleOCR/ppstructure/ python3 predict_system.py
--layout_model_dir=/home/aistudio/PaddleDetection/pretrained_model/picodet_lcnet_x1_0_layout \ #替换成导出的模型 --layout_dict_path=../ppocr/utils/dict/layout_dict/layout_cdla_dict.txt
--vis_font_path=../doc/fonts/simfang.ttf
--recovery=True
--det_model_dir=inference/ch_PP-OCRv3_det_infer
--rec_model_dir=inference/ch_PP-OCRv3_rec_infer
--table_model_dir=inference/ch_ppstructure_mobile_v2.0_SLANet_infer
--rec_char_dict_path=../ppocr/utils/ppocr_keys_v1.txt
--table_char_dict_path=../ppocr/utils/dict/table_structure_dict_ch.txt
--output=../output/
--image_dir=/home/aistudio/test/zx/testtable.pdf

4.运行结果: InvalidArgumentError: The conv2d_fusion Op's Input Variable Input contains uninitialized Tensor. [Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] (at /paddle/paddle/fluid/framework/operator.cc:2094) [operator < conv2d_fusion > error]

请问有人碰到过类似问题吗,是否是导出模型这个步骤有问题

colinlwz avatar May 15 '23 03:05 colinlwz

请问该问题解决了嘛,我也遇到类似问题

shuaihutianxie avatar Jul 31 '23 06:07 shuaihutianxie

请问有人解决了这个问题吗?

wzgwy avatar Oct 18 '23 12:10 wzgwy

我也一样问题 一直没能解决 不管是拿官方的导出 还是自己训练的导出 导出后不可用 不导出都正常

zelohon avatar Oct 23 '23 02:10 zelohon

我也是一样的情况,导出的模型不可用

zzgHiker avatar Nov 07 '23 05:11 zzgHiker

建议使用yolov8,这里有别人预训练的模型:https://github.com/jiangnanboy/layout_analysis

很多文档都是基于好几年前的旧版本写的,paddle及其他组件更新后这些没更新,所以有很多坑。

sralvins avatar Mar 21 '24 05:03 sralvins