1.paddleocr版本2.6.0 paddleDetection版本2.5.0(mac 和 centos 7 上均复现) 2.下载CDLA中文数据集在ai studio中利用:ppyolov2_r50vd_dcn_365e_coco.yml 训练。 3.训练生成best_model.pdparams 利用脚本: python tools/export_model.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --output_dir=./inference_model 导出成model.pdiparams 和 model.pdmodel 静态文件。 4.利用layoutparser(https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl) 能正常输出结构信息。 代码片段,参考: https://aistudio.baidu.com/aistudio/projectdetail/2274897 model = lp.PaddleDetectionLayoutModel(model_path="./checkpoint", threshold=0.5, label_map={1: "Text", 2: "Title", 3: "Figure", 4: "Figure caption", 5: "Table", 6: "Table caption", 7: "Header", 8: "Footer", 9: "Reference", 10: "Equation"}, enforce_cpu=True, enable_mkldnn=False) layout = model.detect(image) show_img = lp.draw_box(image, layout, box_width=5, show_element_type=True)
5.利用PPStructure运行报错误: 代码片段,参考: https://aistudio.baidu.com/aistudio/projectdetail/2274897 table_engine = PPStructure(show_log=True, lang='ch', table=False, layout_model_dir="./checkpoint") files = os.listdir(img_dir) for fi in files: fi_d = os.path.join(img_dir, fi) for img in os.listdir(fi_d): img_path = os.path.join(fi_d, img) img = cv2.imread(img_path) logger.info("table_engine calling .....") result = table_engine(img) save_structure_res(result, os.path.join(save_folder, fi), os.path.basename(img_path).split('.')[0])
异常信息: File "/Users/zengtao/projects/asdc/ocr-helper/venv/lib/python3.9/site-packages/paddleocr/paddleocr.py", line 605, in call res, _ = super().call( File "/Users/zengtao/projects/asdc/ocr-helper/venv/lib/python3.9/site-packages/paddleocr/ppstructure/predict_system.py", line 109, in call layout_res, elapse = self.layout_predictor(img) File "/Users/zengtao/projects/asdc/ocr-helper/venv/lib/python3.9/site-packages/paddleocr/ppstructure/layout/predict_layout.py", line 86, in call self.predictor.run() ValueError: (InvalidArgument) The conv2d Op's Input Variable Input contains uninitialized Tensor. [Hint: Expected t->IsInitialized() == true, but received t->IsInitialized():0 != true:1.] (at /home/Paddle/paddle/fluid/framework/operator.cc:2411) [operator < conv2d > error]
帮忙分析一下原因,谢谢。:)
备注: 动态模型在ai studio 上,利用: python tools/infer.py -c configs/ppyolo/ppyolov2_r50vd_dcn_365e_coco.yml --infer_img=./output/images_00001.png --output_dir=infer_output/ -o weights=./output/ppyolov2_r50vd_dcn_365e_coco/best_model 是能够输出正常结果的。