赞
踩
版面分析ppstructure说明地址:版面分析ppstructure
注:版面分析ppstructure部分内容截图如下。仅作为学习使用,如有侵权,请联系作者删除!
(1)安装PaddlePaddle
pip3 install --upgrade pip
python3 -m pip install paddlepaddle-gpu==2.1.1 -i https://mirror.baidu.com/pypi/simple
python3 -m pip install paddlepaddle==2.1.1 -i https://mirror.baidu.com/pypi/simple
(2)安装Layout-Parser
pip3 install -U https://paddleocr.bj.bcebos.com/whl/layoutparser-0.0.0-py3-none-any.whl
(3)安装paddleocr
PIP快速安装PaddleOCR whl包(仅预测)
pip install "paddleocr>=2.2"
完整克隆PaddleOCR源码(预测+训练)
git clone https://github.com/PaddlePaddle/PaddleOCR
(1)命令行使用
paddleocr --image_dir=1.png --type=structure
(2)Python脚本使用
原图:
import os
import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res
from PIL import Image
def Structure_analysis(img_path):
table_engine = PPStructure(show_log=True)
save_folder = './output/table'
img = cv2.imread(img_path)
result = table_engine(img)
save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])
for line in result:
line.pop('img')
print(line)
font_path = '../doc/fonts/simfang.ttf' # PaddleOCR下提供字体包
image = Image.open(img_path).convert('RGB')
im_show = draw_structure_result(image, result, font_path=font_path)
im_show = Image.fromarray(im_show)
im_show.save('result.jpg')
pass
if __name__ == '__main__':
Structure_analysis('1.png')
pass
效果:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。