【超简单】之基于PaddleX的2022“兴智杯”齿轮瑕疵检测预测部分

简介: 【超简单】之基于PaddleX的2022“兴智杯”齿轮瑕疵检测预测部分

一、模型训练结果


下为后台任务训练visualdl图

image.png


二、模型预测


1.应用模型


  • 后台任务下载训练结果
  • 上传训练模型为数据集并解压缩
# 解压后台训练好的模型
!unzip -qoa data/data166847/best_model.zip


2.解压缩test数据集


# 解压测试数据
!unzip -qoa -O GBK data/data163113/齿轮检测A榜评测数据.zip -d data
!mv data/齿轮检测A榜评测数据 data/test


3.预测结果


%cd ~
import glob
img_file=[]
img_file=glob.glob("data/test/val/*.jpg")
print(len(img_file))   
/home/aistudio
600
import paddlex as pdx
model = pdx.load_model('/home/aistudio/best_model')
result=[]
# 不要批量预测,显存容易爆
for img in img_file:
    item = model.predict(img)
    result.append(item)
print(result[0])
[{'category_id': 0, 'category': 'hp_cm', 'bbox': [277.3127746582031, 398.80572509765625, 116.0015869140625, 123.09124755859375], 'score': 0.2651117742061615}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [270.89251708984375, 242.0045928955078, 131.30450439453125, 115.49867248535156], 'score': 0.18997494876384735}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [266.58856201171875, 69.13514709472656, 127.87396240234375, 108.75114440917969], 'score': 0.09731187671422958}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [271.2421875, 556.1539306640625, 118.46600341796875, 108.4219970703125], 'score': 0.09247241914272308}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [270.625244140625, 232.81887817382812, 91.84698486328125, 79.2542724609375], 'score': 0.03366655856370926}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [343.02398681640625, 0.6909008026123047, 73.678466796875, 42.58038520812988], 'score': 0.025596577674150467}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [275.1397705078125, 367.2425231933594, 76.25787353515625, 66.8385009765625], 'score': 0.015586825087666512}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [267.201416015625, 514.007568359375, 45.40545654296875, 66.0347900390625], 'score': 0.011892958544194698}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [268.7194519042969, 714.6714477539062, 44.30950927734375, 56.0875244140625], 'score': 0.011540604755282402}, {'category_id': 0, 'category': 'hp_cm', 'bbox': [261.60333251953125, 220.31338500976562, 59.601318359375, 71.15499877929688], 'score': 0.010460827499628067}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [266.58856201171875, 69.13514709472656, 127.87396240234375, 108.75114440917969], 'score': 0.352761834859848}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [771.477783203125, 8.217887878417969, 362.9459228515625, 212.39063262939453], 'score': 0.1544414609670639}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [412.41827392578125, 0.0, 687.5846557617188, 373.23834228515625], 'score': 0.1034211814403534}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [270.89251708984375, 242.0045928955078, 131.30450439453125, 115.49867248535156], 'score': 0.10121399909257889}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [271.2421875, 556.1539306640625, 118.46600341796875, 108.4219970703125], 'score': 0.09936320781707764}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [229.65936279296875, 71.80953979492188, 937.6921997070312, 630.4786682128906], 'score': 0.06198175996541977}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [277.3127746582031, 398.80572509765625, 116.0015869140625, 123.09124755859375], 'score': 0.0524945892393589}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [343.02398681640625, 0.6909008026123047, 73.678466796875, 42.58038520812988], 'score': 0.04534951224923134}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [268.7194519042969, 714.6714477539062, 44.30950927734375, 56.0875244140625], 'score': 0.01778482086956501}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [226.39495849609375, 376.0963439941406, 914.5798950195312, 617.7748718261719], 'score': 0.016559403389692307}, {'category_id': 1, 'category': 'hp_cd', 'bbox': [270.625244140625, 232.81887817382812, 91.84698486328125, 79.2542724609375], 'score': 0.015641620382666588}, {'category_id': 2, 'category': 'kp', 'bbox': [266.58856201171875, 69.13514709472656, 127.87396240234375, 108.75114440917969], 'score': 0.021044017747044563}, {'category_id': 2, 'category': 'kp', 'bbox': [939.2327270507812, 18.061260223388672, 80.750244140625, 52.013065338134766], 'score': 0.01880461722612381}, {'category_id': 2, 'category': 'kp', 'bbox': [879.6025390625, 987.5177001953125, 61.5970458984375, 51.7886962890625], 'score': 0.017387624830007553}, {'category_id': 2, 'category': 'kp', 'bbox': [277.3127746582031, 398.80572509765625, 116.0015869140625, 123.09124755859375], 'score': 0.014427728950977325}]
print(len(result))
600


4.按格式保存并提交


import json
import os
result_json = []
for i in range(len(result)):
    for item in result[i]:
        dt = {}
        dt['name'] = os.path.basename(img_file[i])
        dt['category_id'] = item['category_id']
        dt['bbox'] = item['bbox']
        dt['score'] = item['score']
        result_json.append(dt)
# 生成上传文件
with open('./result.json','w') as f:
    json.dump(result_json, f)


三、改进空间


  • 由于采用后台训练模式,可增大训练轮次,不用担心训练中断;
  • 可结合visualdl 训练图来调整训练策略。


目录
相关文章
|
并行计算 算法 计算机视觉
【MATLAB 】 ICEEMDAN 信号分解+模糊熵(近似熵)算法
【MATLAB 】 ICEEMDAN 信号分解+模糊熵(近似熵)算法
1204 0
|
安全 网络协议 网络安全
端口转发:解锁网络访问的新维度
端口转发技术,简化网络数据流,用于家庭至企业服务器场景。它隐藏内部网络服务,提供远程访问、个人网站公开、NAT穿透及安全的VPN连接。设置涉及路由器管理界面,添加转发规则,但需注意安全风险,仅开放必要端口并加强内部安全措施。了解和善用端口转发,提升网络服务可达性与安全性。
1276 5
|
移动开发 前端开发 UED
React 音频预览组件:Audio Preview
本文介绍如何使用 React 构建音频预览组件,涵盖基础实现、常见问题及解决方案。通过 HTML5 `<audio>` 标签和 React 状态管理,实现播放控制。解决文件路径、浏览器兼容性等问题,并优化性能,避免状态不同步和内存泄漏,提升用户体验。
310 22
|
Java 数据库连接 数据库
spring复习05,spring整合mybatis,声明式事务
这篇文章详细介绍了如何在Spring框架中整合MyBatis以及如何配置声明式事务。主要内容包括:在Maven项目中添加依赖、创建实体类和Mapper接口、配置MyBatis核心配置文件和映射文件、配置数据源、创建sqlSessionFactory和sqlSessionTemplate、实现Mapper接口、配置声明式事务以及测试使用。此外,还解释了声明式事务的传播行为、隔离级别、只读提示和事务超时期间等概念。
spring复习05,spring整合mybatis,声明式事务
|
算法 定位技术 C++
A* 算法详解(超级详细讲解,附有大图)
A* 算法详解(超级详细讲解,附有大图)
9899 0
|
前端开发 JavaScript 开发工具
【React】使用Next.js构建并部署个人博客
【React】使用Next.js构建并部署个人博客
【React】使用Next.js构建并部署个人博客
|
传感器 开发框架 运维
【超简单】之基于PaddleX的2022“兴智杯”齿轮瑕疵检测训练
【超简单】之基于PaddleX的2022“兴智杯”齿轮瑕疵检测训练
869 0
【超简单】之基于PaddleX的2022“兴智杯”齿轮瑕疵检测训练
|
机器学习/深度学习 数据处理 计算机视觉
LabelStudio环境搭建以及使用且解除上传文件限制
LabelStudio是开源的数据标注工具,支持多种类型如文本、图像、音频、视频的标注任务。它具有多种标注类型、可扩展性、团队协作和版本控制等功能,并可在本地、云端或Docker中部署。通过设置环境变量`DATA_UPLOAD_MAX_NUMBER_FILES`,可以解除上传文件数量限制。使用Docker安装时,可运行包含该变量的命令以启动容器,并通过http://localhost:8080访问。遇到文件数限制问题,可增大此变量值以解决。
4880 3
|
XML 数据可视化 算法
目标检测YOLO数据集的三种格式及转换
目标检测YOLO数据集的三种格式及转换
Linux Command split 切割文件
Linux Command split 切割文件