Fork me on GitHub

中文文档图片版面检测

项目地址:https://github.com/jiangnanboy/layout_analysis

模型训练及推理

本项目根据开源中文版面数据CDLA ,利用yolov8训练两个模型8mpt与8npt,

CDLA是一个中文文档版面分析数据集,面向中文文献类(论文)场景。包含以下10个label:

正文标题图片图片标题表格表格标题页眉页脚注释公式
Text Title Figure Figure caption Table Table caption Header Footer Reference Equation

训练:

from ultralytics import YOLO

def train_model():
    # 加载模型
    print('model load。。。')
    model = YOLO("8npt/best.pt")  # 加载模型
    print('model load completed。。。')
    #使用模型
    model.train(data="img-layout.yaml", epochs=300, device=1)# , lr0=0.0001)  # 训练模型
    metrics = model.val()  # 在验证集上评估模型性能

8npt

 

8mpt

 

推理:

from ultralytics import YOLO
def infer():
    model = YOLO('8npt/best.pt')
    results = model('img.jpg')
    print(results[0].plot())
    cv2.imwrite('result.png', results[0].plot())

 

posted @   石头木  阅读(815)  评论(1编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示