探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统

前面也有讲过将智能模型应用和工业等领域结合起来是有不错市场前景的,比如:布匹瑕疵检测、瓷砖瑕疵检测、PCB缺陷检测等等,在工业领域内也有很多可为的方向,本文的核心目的就是想要基于目标检测模型来开发构建焊接缺陷检测模型,探索分析工业领域智能化检测。

首先看下效果图:

 接下来看下数据集情况:

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第1张图片

 YOLO格式标注文件如下所示:

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第2张图片

 VOC格式标注文件如下所示:

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第3张图片

 这里共有10种缺陷类别,如下:

0: chongkong
1: hanfeng
2: yueyawan
3: shuiban
4: youban
5: siban
6: yiwu
7: yahen
8: zhehen
9: yaozhe

训练数据配置如下:

# Dataset
path: ./dataset
train:
  - images/train
val:
  - images/test
test:
  - images/test



# Classes
names:
  0: chongkong
  1: hanfeng
  2: yueyawan
  3: shuiban
  4: youban
  5: siban
  6: yiwu
  7: yahen
  8: zhehen
  9: yaozhe

模型文件如下:

# YOLOv5  by Ultralytics, GPL-3.0 license

# Parameters
nc: 10  # number of classes
depth_multiple: 0.33  # model depth multiple
width_multiple: 0.50  # layer channel multiple
anchors:
  - [10,13, 16,30, 33,23]  # P3/8
  - [30,61, 62,45, 59,119]  # P4/16
  - [116,90, 156,198, 373,326]  # P5/32


#Backbone
backbone:
  # [from, number, module, args]
  [[-1, 1, Conv, [64, 6, 2, 2]],  # 0-P1/2
   [-1, 1, Conv, [128, 3, 2]],  # 1-P2/4
   [-1, 3, C3, [128]],
   [-1, 1, Conv, [256, 3, 2]],  # 3-P3/8
   [-1, 6, C3, [256]],
   [-1, 1, Conv, [512, 3, 2]],  # 5-P4/16
   [-1, 9, C3, [512]],
   [-1, 1, Conv, [1024, 3, 2]],  # 7-P5/32
   [-1, 3, C3, [1024]],
   [-1, 1, SPPF, [1024, 5]],  # 9
  ]


#Head
head:
  [[-1, 1, Conv, [512, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 6], 1, Concat, [1]],  # cat backbone P4
   [-1, 3, C3, [512, False]],  # 13

   [-1, 1, Conv, [256, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, 'nearest']],
   [[-1, 4], 1, Concat, [1]],  # cat backbone P3
   [-1, 3, C3, [256, False]],  # 17 (P3/8-small)

   [-1, 1, Conv, [256, 3, 2]],
   [[-1, 14], 1, Concat, [1]],  # cat head P4
   [-1, 3, C3, [512, False]],  # 20 (P4/16-medium)

   [-1, 1, Conv, [512, 3, 2]],
   [[-1, 10], 1, Concat, [1]],  # cat head P5
   [-1, 3, C3, [1024, False]],  # 23 (P5/32-large)

   [[17, 20, 23], 1, Detect, [nc, anchors]],  # Detect(P3, P4, P5)
  ]

默认执行100次epoch的迭代计算,日志输出如下:

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      90/99      6.85G    0.02526    0.01224  0.0009257         14        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.821      0.735      0.776      0.402

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      91/99      6.85G    0.02506    0.01192  0.0007306         15        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.828      0.768      0.786      0.416

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      92/99      6.85G    0.02498    0.01206  0.0009537         10        640: 100%|██████████| 61/61 [03:18<00:00,  3.26s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705        0.8      0.773      0.785      0.417

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      93/99      6.85G      0.025     0.0122  0.0009593         19        640: 100%|██████████| 61/61 [03:19<00:00,  3.27s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.21s/it]
                   all        459        705      0.826      0.753       0.79      0.419

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      94/99      6.85G    0.02482      0.012  0.0006241         13        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.799      0.775      0.787      0.422

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      95/99      6.85G    0.02466    0.01168  0.0007662         14        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.808      0.777      0.785      0.418

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      96/99      6.85G    0.02445     0.0119   0.000781         16        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.21s/it]
                   all        459        705      0.826      0.771      0.789      0.431

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      97/99      6.85G    0.02411     0.0119  0.0007069         20        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.841      0.745      0.787      0.423

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      98/99      6.85G    0.02392    0.01177  0.0007471         15        640: 100%|██████████| 61/61 [03:18<00:00,  3.25s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.838      0.764      0.788      0.417

      Epoch    GPU_mem   box_loss   obj_loss   cls_loss  Instances       Size
      99/99      6.85G    0.02369    0.01159  0.0006575         15        640: 100%|██████████| 61/61 [03:18<00:00,  3.26s/it]
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:17<00:00,  2.20s/it]
                   all        459        705      0.847      0.758      0.787      0.425

100 epochs completed in 6.023 hours.
Optimizer stripped from runs/train/yolov5s/weights/last.pt, 14.4MB
Optimizer stripped from runs/train/yolov5s/weights/best.pt, 14.4MB

Validating runs/train/yolov5s/weights/best.pt...
Fusing layers... 
YOLOv5s summary: 157 layers, 7037095 parameters, 0 gradients, 15.8 GFLOPs
                 Class     Images  Instances          P          R      mAP50   mAP50-95: 100%|██████████| 8/8 [00:18<00:00,  2.34s/it]
                   all        459        705      0.826      0.771      0.789      0.431
             chongkong        459         73      0.973      0.977      0.984      0.544
               hanfeng        459        118      0.918      0.983      0.953      0.576
              yueyawan        459         71      0.875      0.987      0.961      0.635
               shuiban        459         79      0.733      0.764      0.779      0.438
                youban        459         87       0.67      0.747      0.747      0.385
                 siban        459        154      0.767      0.749      0.771      0.402
                  yiwu        459         55      0.592       0.58      0.531      0.215
                 yahen        459         17          1       0.38      0.459      0.233
                zhehen        459         23       0.86      0.652      0.745      0.317
                yaozhe        459         28      0.873      0.893       0.96      0.567
Results saved to runs/train/yolov5s

接下来看下结果详情:
【标签类别可视化】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第4张图片

 【训练日志可视化】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第5张图片

 【混淆矩阵】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第6张图片

 【F1值曲线和PR曲线可视化】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第7张图片

 【精确率和召回率曲线可视化】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第8张图片

 【训练集batch计算实例】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第9张图片

 【测试集batch计算实例】

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第10张图片

 可视化推理实例如下:

探索工业智能检测,基于轻量级YOLOv5s开发构建焊接缺陷检测识别系统_第11张图片

你可能感兴趣的:(YOLO)