使用Paddleclas完成半导体晶圆图谱缺陷种类识别

★★★ 本文源自AI Studio社区精品项目,【点击此处】查看更多精品内容 >>>


1. 项目背景

半导体晶圆作为集成电路的载体,在制造过程中需要反复的经过复杂的薄膜、光刻、刻蚀等工序。而这些制造过程中工序的异常会导致晶圆缺陷的产生。
在晶圆质检中,利用电学测试设备对晶圆片上的每颗晶粒进行电性测试,可得到用于描述晶圆缺陷状态的晶圆图谱。如下图所示:

在上图中,每个小方块即是晶圆上的一颗芯片,有颜色标识的即为测试异常的芯片。对晶圆上有缺陷的芯片的空间分布图谱的模式进行识别分析,可有效辅助识别制造过程中的缺陷根源,并有针对性的进行改进和预防,从而提升晶圆制造的产品良率。
例如上图中有部分长条状的连续实效,可能是划伤等造成。

本项目利用开源的WM-811K晶圆缺陷图谱数据集和飞桨的Paddleclas套件进行晶圆缺陷分类图谱分析,
演示如何使用paddleclas快速搭建一个完整的图像分类方案,从数据集准备、到模型训练、验证、测试以及相应的部署

2. 数据集介绍

本项目采用开源的WM-811K数据集。原始数据可以从该网站下载: http://mirlab.org/dataSet/public/

需要注意的是从该网站上下载下来的数据分为两种, MATLAB格式的.mat文件和python序列化后的.pkl文件。
该数据集共收集了811457张晶圆测试后的图片。但是要注意,其中只有172950做了标签,将实效按照芯片的空间分布分类成9个类别(0,1,2…8)。

此处,笔者已经将python的.pkl文件转成image, 并在每个类别选取了部分用于制作paddleclas图片分类的数据集。该数据集位于本项目的data/data188959/ 目录下,fork本项目后即可查看。

# 查看当前挂载的数据集目录
!ls /home/aistudio/data/data188959/
waferMap.zip
# 解压数据
!unzip /home/aistudio/data/data188959/waferMap.zip -d /home/aistudio/work/
# 查看数据集的结构
!tree -L 1 /home/aistudio/work/
/home/aistudio/work/
├── img
├── label_list.txt
├── test
├── train.txt
└── val.txt

2 directories, 3 files
  • dataset下面有两个文件夹:img和test存放jpg格式的晶圆图谱图片,格式已经转成jpg
  • 按照paddleclas的要求,准备训练数据集train.txt和验证数据集val.txt, 格式如下: 每一行为一个样本, 后面为该样本的标签
# 查看train.txt文件的前10行
!head -10 /home/aistudio/work/train.txt
Center_101787.jpg 0
Center_106264.jpg 0
Center_106289.jpg 0
Center_106598.jpg 0
Center_106656.jpg 0
Center_106681.jpg 0
Center_108074.jpg 0
Center_109733.jpg 0
Center_110027.jpg 0
Center_110052.jpg 0

3. 数据预览

此处主要对每种缺陷的图谱进行可视化预览,对数据有基本的认识.
在数据集中有个label_list.txt文件, 该文件中包含了每种缺陷的标签(0-8)及其对应的缺陷名称。下面使用该文件创建缺陷名称,并选择相应的图片进行可视化.

在train.txt文件中,每种缺陷随机选择5个样本进行可视化

# 导入必要的第三方库
import os
import random
import matplotlib.pyplot as plt
import cv2

defect_dict = {0: "Center", 1:"Donut", 2:"Edge-Loc", 3:"Edge-Ring", 4:"Loc", 5:"Random", 6:"Scratch",7:"Near-full"}
img_list = os.listdir("/home/aistudio/work/img")
img_list[:5]
['Random_756754.jpg',
 'Edge-Loc_136053.jpg',
 'Scratch_290111.jpg',
 'Loc_292367.jpg',
 'Edge-Ring_157663.jpg']
# 从每种缺陷中随机选取3张图片进行可视化展示
single_defect_num = 3
select_list = []

for defect in defect_dict.values():
    print(f'select image for defect {defect}...')
    begain = 0
    while(begain<single_defect_num):
        img_select = random.choice(img_list)
        img_type = img_select.split('_')[0]
        if img_type == defect and img_select not in select_list:
            select_list.append(img_select)
            print(f"img {img_select} select and put to the select list")
            begain+=1
        if begain>=single_defect_num:
            break
print(select_list)

select image for defect Center...
img Center_211910.jpg select and put to the select list
img Center_288311.jpg select and put to the select list
img Center_158966.jpg select and put to the select list
select image for defect Donut...
img Donut_679843.jpg select and put to the select list
img Donut_280031.jpg select and put to the select list
img Donut_279127.jpg select and put to the select list
select image for defect Edge-Loc...
img Edge-Loc_810655.jpg select and put to the select list
img Edge-Loc_428458.jpg select and put to the select list
img Edge-Loc_760254.jpg select and put to the select list
select image for defect Edge-Ring...
img Edge-Ring_21013.jpg select and put to the select list
img Edge-Ring_359889.jpg select and put to the select list
img Edge-Ring_353119.jpg select and put to the select list
select image for defect Loc...
img Loc_85161.jpg select and put to the select list
img Loc_811236.jpg select and put to the select list
img Loc_129921.jpg select and put to the select list
select image for defect Random...
img Random_776014.jpg select and put to the select list
img Random_764577.jpg select and put to the select list
img Random_243259.jpg select and put to the select list
select image for defect Scratch...
img Scratch_716878.jpg select and put to the select list
img Scratch_348197.jpg select and put to the select list
img Scratch_301867.jpg select and put to the select list
select image for defect Near-full...
img Near-full_929.jpg select and put to the select list
img Near-full_696564.jpg select and put to the select list
img Near-full_256910.jpg select and put to the select list
['Center_211910.jpg', 'Center_288311.jpg', 'Center_158966.jpg', 'Donut_679843.jpg', 'Donut_280031.jpg', 'Donut_279127.jpg', 'Edge-Loc_810655.jpg', 'Edge-Loc_428458.jpg', 'Edge-Loc_760254.jpg', 'Edge-Ring_21013.jpg', 'Edge-Ring_359889.jpg', 'Edge-Ring_353119.jpg', 'Loc_85161.jpg', 'Loc_811236.jpg', 'Loc_129921.jpg', 'Random_776014.jpg', 'Random_764577.jpg', 'Random_243259.jpg', 'Scratch_716878.jpg', 'Scratch_348197.jpg', 'Scratch_301867.jpg', 'Near-full_929.jpg', 'Near-full_696564.jpg', 'Near-full_256910.jpg']
# 按照顺序可视化选择的图片: 8中缺陷,8*3=24张图片
plt.figure(figsize=(10,15))
for index, _ in enumerate(select_list):
    img_path = os.path.join("/home/aistudio/work/img", _)
    img_data = cv2.imread(img_path)
    plt.subplot(8, 3, index+1)
    plt.imshow(img_data[:, :, ::-1])
    plt.title(_, fontsize=6)
    plt.axis("off")

在这里插入图片描述

根据图片和缺陷的名称,可以大概了解每种缺陷的分类方法,例如:

  • Certer: 大部分缺陷的芯粒位于晶圆圆心附近
  • Donut: 缺陷的芯粒空间分布类似于一个甜甜圈
  • Loc: 局部出现缺陷芯粒聚集

4. 开发环境准备

本项目使用paddleclas套件进行图谱分类算法模型的训练和验证,需要安装paddleclas以及相应的工具
配置paddleclas的运行环境,主要步骤如下:

  • 克隆 PaddleClas
  • 安装 Python 依赖库

4.1. 下载paddleclas

执行git clone命令下载, github比较慢,可以从gitee上下载。
另外,本项目打包了一份paddleclas在环境,使用时直接解压即可

# 可以从github或者gitee上使用!git clone命令下载Paddleclas到本环境中
# !git clone https://gitee.com/paddlepaddle/PaddleClas

# 此处,直接解压下载好的
%cd /home/aistudio
!unzip -q /home/aistudio/PaddleClas.zip 
/home/aistudio

4.2 安装相应的依赖

使用pip install命令安装paddleclas根目录下的requirments.txt即可, 同时可以设置镜像,加速安装

# 安装相关依赖
%cd /home/aistudio/PaddleClas
!pip install --upgrade -r requirements.txt -i https://mirror.baidu.com/pypi/simple

5. 选择模型训练

配置好Paddleclas的运行环境后,可以使用paddleclas套件内的模型直接进行训练。

这也是使用套件的好处,模型组网已经完成,直接修改config配置文件即可完成模型的训练,非常高效!

本项目,我们使用用于服务器端部署的Resnet模型和移动端部署的MobileNet模型来进行演示

5.1 使用Resnet50模型进行训练

有了paddleclas开发套件,只需要将对应模型的yaml文件按照自己的项目配置进行更改即可。主要是要指定数据集的位置以及相应的优化器配置。

对于Resnet50, 相应的config文件位置为:PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml

对于该模型,我们作如下配置进行训练:

  • epochs:200(所有的数据走一遍前向计算和反向梯度更新为一个epoch)
  • learning rate: 0.01
  • learning rate schduler: PiecewiseDecay

需要修改的部分如下:

"""
Global
 ...
 epochs: 200
 print_batch_step: 10
 use_visualdl: True # 设置为true会将训练过程中的参数变化保存起来,便于使用visualdl可视化训练过程

Optimizer:
  ...
  lr:
    name: Piecewise
    learning_rate: 0.01
    decay_epochs: [50, 100, 150]
    values: [0.01, 0.005, 0.001, 0.0005]
 
 DataLoader:
  Train:
    dataset:
      name: ImageNetDataset
      image_root: /home/aistudio/work/img 
      cls_label_path: /home/aistudio/work/train.txt
      ...
  Eval:
    dataset: 
      name: ImageNetDataset
      image_root: /home/aistudio/work/img
      cls_label_path: /home/aistudio/work/val.txt 
      ...
Infer:
  infer_dir: /home/aistudio/work/test
  batch_size: 10
  ...
  PostProcess:
    name: Topk
    topk: 5
    class_id_map_file: /home/aistudio/work/label_list.txt
"""
'\nGlobal\n ...\n epochs: 200\n print_batch_step: 10\n use_visualdl: True # 设置为true会将训练过程中的参数变化保存起来,便于使用visualdl可视化训练过程\n\nOptimizer:\n  ...\n  lr:\n    name: Piecewise\n    learning_rate: 0.01\n    decay_epochs: [50, 100, 150]\n    values: [0.01, 0.005, 0.001, 0.0005]\n \n DataLoader:\n  Train:\n    dataset:\n      name: ImageNetDataset\n      image_root: /home/aistudio/work/img \n      cls_label_path: /home/aistudio/work/train.txt\n      ...\n  Eval:\n    dataset: \n      name: ImageNetDataset\n      image_root: /home/aistudio/work/img\n      cls_label_path: /home/aistudio/work/val.txt \n\n'
  • 通过修改后的config文件可以看出,主要就是修改数据集的路径。其他大部分都可以使用默认的参数
  • 另外,项目跑通之后,可以在此处修改其他参数,尝试不同参数是否可以提升模型精度,这就是常说的深度学习“炼丹”
  • 对于后面MobileNet的模型配置文件的修改大体类似,就不在赘述
# 使用toos/train.py脚本开启一键训练
%cd /home/aistudio/PaddleClas
!python tools/train.py \
        -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml
        
  • 训练结果可视化
Acc: 88.8%learning rate decayLoss
  • 将训练过程可视化可以方便的观察训练过程的变化。差不多150个epoch之后,模型的精度稳定到0.85以上
  • 另外,可以直观的看到学习率采用PiecewiseDecay方式衰减的变化趋势,这个可以和后面MobileNet的cosin下降方式对比

5.2: 移动端部署模型: MobileNetV3

  • 模型配置:

    • Arch:MobileNetV3_large_x0_75
    • lr: base 0.5 + consin decay
    • warmip: 5 epich
    • epochs: 360
    • batchsize: 128
  • 相应的修改可以参考ResNet的config文件修改,这里省略

# 训练
%cd /home/aistudio/PaddleClas
!python tools/train.py \
        -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml
  • 训练过程可视化
Eval_AccLearningRateLoss
  • 通过图片可以直观的看到对于learning rate加入warmup作为冷启动后的效果, 模型可以快速收敛
  • 另外,在训练过程中,如果有报shared memory相关的错误,可能是内存不足。可以尝试将batchSize改小 本项目实测, Tesla V100 32G环境可以支持batch size = 128

6. 模型评估

在训练过程中,我们可以在训练的脚本中加入 --eval,可以实现一边训练一边评估。

另外,在训练结束之后,我们也可以单独对模型进行评估, 运行tools/eval.py脚本,同时指定模型的位置即可

6.1 评估ResNet50模型

%cd /home/aistudio/PaddleClas/
!python tools/eval.py \
    -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
    -o Global.pretrained_model=/home/aistudio/PaddleClas/output/ResNet50/best_model

6.2 评估MobileNetV3端侧模型

%cd /home/aistudio/PaddleClas/
!python tools/eval.py \
    -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml \
    -o Global.pretrained_model=/home/aistudio/PaddleClas/output/MobileNetV3_large_x0_75/best_model
  • 注意,模型评估时模型在验证集上的测试结果,通过对比模型的预测值和图片的真实标签计算模型的精度等指标
  • 模型评估主要用于判断训练完成后的模型精度等指标是否满足部署要求,主要关注Loss,TopK精度以及速度ips等指标

7. 模型预测

完成评估后,可以使用tools/infer.py脚本进行单张图片或者多张图片批量预测。
在预测脚本中传入使用的模型和测试的图片路径即可。

%cd /home/aistudio/PaddleClas/
!python tools/infer.py \
    -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
    -o Global.pretrained_model=/home/aistudio/PaddleClas/output/ResNet50/best_model \
    -o Infer.infer_imgs=/home/aistudio/work/test/Center_85238.jpg  # 单张图片
    

8. 模型导出部署

paddlepaddle支持导出 inference 模型用于部署推理场景,相比于训练调优场景,inference 模型会将网络权重与网络结构进行持久化存储,并且 PaddlePaddle 支持使用预测引擎加载 inference 模型进行预测推理。

在paddleclas套件中通过tools/export_model.py导出模型。导出后,将生成以下三个文件:

  • inference.pdmodel:用于存储网络结构信息;
  • inference.pdiparams:用于存储网络权重信息;
  • inference.pdiparams.info:用于存储模型的参数信息,在分类模型和识别模型中可忽略

8.1 导出ResNet50模型

%cd /home/aistudio/PaddleClas/
!python tools/export_model.py \
    -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/ResNet/ResNet50.yaml \
    -o Global.pretrained_model=/home/aistudio/PaddleClas/output/ResNet50/best_model \
    -o Global.save_inference_dir=deploy/models/ResNet50
# 查看导出后的模型文件结构
!tree -L 2 deploy/models/ResNet50
deploy/models/ResNet50
├── inference.pdiparams
├── inference.pdiparams.info
└── inference.pdmodel

0 directories, 3 files
!tree -L 2 deploy/models/InceptionV4
deploy/models/InceptionV4
├── inference.pdiparams
├── inference.pdiparams.info
└── inference.pdmodel

0 directories, 3 files

8.2 导出MobileNet模型

%cd /home/aistudio/PaddleClas/
!python tools/export_model.py \
    -c /home/aistudio/PaddleClas/ppcls/configs/ImageNet/MobileNetV3/MobileNetV3_large_x0_75.yaml \
    -o Global.pretrained_model=/home/aistudio/PaddleClas/output/MobileNetV3_large_x0_75/best_model \
    -o Global.save_inference_dir=deploy/models/MobileNetV3_large_x0_75
!tree -L 2 /home/aistudio/PaddleClas/deploy/models/MobileNetV3_large_x0_75
/home/aistudio/PaddleClas/deploy/models/MobileNetV3_large_x0_75
├── inference.pdiparams
├── inference.pdiparams.info
└── inference.pdmodel

0 directories, 3 files

9. 推理

  • 使用导出的模型
  • 脚本位于deploy/python.predict_cls.py
  • 修改配置文件

9.1 使用ResNet50模型

%cd /home/aistudio/PaddleClas/deploy
!python python/predict_cls.py \
     -c configs/inference_cls.yaml
[Errno 2] No such file or directory: 'deploy'
/home/aistudio/PaddleClas/deploy
2022-12-01 11:39:58 INFO: Loading faiss with AVX2 support.
2022-12-01 11:39:58 INFO: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-12-01 11:39:58 INFO: Loading faiss.
2022-12-01 11:39:58 INFO: Successfully loaded faiss.
2022-12-01 11:39:59 INFO: 
===========================================================
==        PaddleClas is powered by PaddlePaddle !        ==
===========================================================
==                                                       ==
==   For more info please go to the following website.   ==
==                                                       ==
==       https://github.com/PaddlePaddle/PaddleClas      ==
===========================================================

2022-12-01 11:39:59 INFO: Global : 
2022-12-01 11:39:59 INFO:     batch_size : 1
2022-12-01 11:39:59 INFO:     cpu_num_threads : 10
2022-12-01 11:39:59 INFO:     enable_benchmark : True
2022-12-01 11:39:59 INFO:     enable_mkldnn : True
2022-12-01 11:39:59 INFO:     enable_profile : False
2022-12-01 11:39:59 INFO:     gpu_mem : 8000
2022-12-01 11:39:59 INFO:     infer_imgs : /home/aistudio/work/wafer_img/dataset/test
2022-12-01 11:39:59 INFO:     inference_model_dir : /home/aistudio/PaddleClas/deploy/models/ResNet50
2022-12-01 11:39:59 INFO:     ir_optim : True
2022-12-01 11:39:59 INFO:     use_fp16 : False
2022-12-01 11:39:59 INFO:     use_gpu : True
2022-12-01 11:39:59 INFO:     use_tensorrt : False
2022-12-01 11:39:59 INFO: PostProcess : 
2022-12-01 11:39:59 INFO:     SavePreLabel : 
2022-12-01 11:39:59 INFO:         save_dir : ./pre_label/
2022-12-01 11:39:59 INFO:     Topk : 
2022-12-01 11:39:59 INFO:         class_id_map_file : /home/aistudio/work/wafer_img/dataset/label_list.txt
2022-12-01 11:39:59 INFO:         topk : 5
2022-12-01 11:39:59 INFO:     main_indicator : Topk
2022-12-01 11:39:59 INFO: PreProcess : 
2022-12-01 11:39:59 INFO:     transform_ops : 
2022-12-01 11:39:59 INFO:         ResizeImage : 
2022-12-01 11:39:59 INFO:             resize_short : 256
2022-12-01 11:39:59 INFO:         CropImage : 
2022-12-01 11:39:59 INFO:             size : 224
2022-12-01 11:39:59 INFO:         NormalizeImage : 
2022-12-01 11:39:59 INFO:             channel_num : 3
2022-12-01 11:39:59 INFO:             mean : [0.485, 0.456, 0.406]
2022-12-01 11:39:59 INFO:             order : 
2022-12-01 11:39:59 INFO:             scale : 0.00392157
2022-12-01 11:39:59 INFO:             std : [0.229, 0.224, 0.225]
2022-12-01 11:39:59 INFO:         ToCHWImage : None
Center_119628.jpg:	class id(s): [0, 4, 6, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Scratch', 'Edge-Loc', 'Random']
Center_119714.jpg:	class id(s): [0, 4, 2, 6, 1], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Edge-Loc', 'Scratch', 'Donut']
Center_187048.jpg:	class id(s): [0, 2, 4, 3, 1], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Edge-Loc', 'Loc', 'Edge-Ring', 'Donut']
Center_190340.jpg:	class id(s): [0, 4, 1, 2, 6], score(s): [0.99, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Donut', 'Edge-Loc', 'Scratch']
Center_202124.jpg:	class id(s): [0, 1, 4, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Donut', 'Loc', 'Edge-Loc', 'Random']
Center_49.jpg:	class id(s): [0, 4, 2, 6, 1], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Edge-Loc', 'Scratch', 'Donut']
Center_7290.jpg:	class id(s): [0, 4, 1, 2, 6], score(s): [0.91, 0.08, 0.01, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Donut', 'Edge-Loc', 'Scratch']
Center_83419.jpg:	class id(s): [0, 4, 2, 5, 1], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Edge-Loc', 'Random', 'Donut']
Center_85238.jpg:	class id(s): [0, 4, 1, 2, 3], score(s): [0.76, 0.24, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Donut', 'Edge-Loc', 'Edge-Ring']
Center_96002.jpg:	class id(s): [0, 4, 2, 1, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Center', 'Loc', 'Edge-Loc', 'Donut', 'Scratch']
Donut_116252.jpg:	class id(s): [1, 4, 2, 5, 7], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Random', 'Near-full']
Donut_244230.jpg:	class id(s): [1, 4, 2, 5, 6], score(s): [0.93, 0.07, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Random', 'Scratch']
Donut_278979.jpg:	class id(s): [1, 4, 2, 6, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Scratch', 'Random']
Donut_279135.jpg:	class id(s): [1, 4, 2, 6, 5], score(s): [0.98, 0.02, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Scratch', 'Random']
Donut_279770.jpg:	class id(s): [1, 5, 2, 7, 4], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Random', 'Edge-Loc', 'Near-full', 'Loc']
Donut_279845.jpg:	class id(s): [1, 5, 4, 2, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Random', 'Loc', 'Edge-Loc', 'Scratch']
Donut_680504.jpg:	class id(s): [1, 6, 4, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Scratch', 'Loc', 'Edge-Loc', 'Random']
Donut_683294.jpg:	class id(s): [1, 4, 6, 0, 2], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Scratch', 'Center', 'Edge-Loc']
Donut_7334.jpg:	class id(s): [1, 5, 2, 4, 7], score(s): [0.96, 0.04, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Random', 'Edge-Loc', 'Loc', 'Near-full']
Donut_7936.jpg:	class id(s): [1, 4, 2, 5, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Random', 'Scratch']
Edge-Loc_24967.jpg:	class id(s): [2, 3, 4, 6, 0], score(s): [0.96, 0.03, 0.01, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Edge-Ring', 'Loc', 'Scratch', 'Center']
Edge-Loc_29429.jpg:	class id(s): [2, 4, 3, 5, 7], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Loc', 'Edge-Ring', 'Random', 'Near-full']
Edge-Loc_36.jpg:	class id(s): [2, 6, 4, 0, 5], score(s): [0.63, 0.26, 0.11, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Scratch', 'Loc', 'Center', 'Random']
Edge-Loc_41932.jpg:	class id(s): [2, 4, 6, 1, 0], score(s): [0.71, 0.19, 0.08, 0.01, 0.00], label_name(s): ['Edge-Loc', 'Loc', 'Scratch', 'Donut', 'Center']
Edge-Loc_45091.jpg:	class id(s): [2, 3, 4, 6, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Edge-Ring', 'Loc', 'Scratch', 'Random']
Edge-Loc_48272.jpg:	class id(s): [4, 6, 2, 0, 5], score(s): [0.49, 0.44, 0.05, 0.02, 0.00], label_name(s): ['Loc', 'Scratch', 'Edge-Loc', 'Center', 'Random']
Edge-Loc_54178.jpg:	class id(s): [2, 4, 1, 5, 3], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Loc', 'Donut', 'Random', 'Edge-Ring']
Edge-Loc_58508.jpg:	class id(s): [3, 2, 6, 4, 5], score(s): [0.82, 0.18, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Scratch', 'Loc', 'Random']
Edge-Loc_7369.jpg:	class id(s): [2, 4, 0, 6, 5], score(s): [0.97, 0.03, 0.00, 0.00, 0.00], label_name(s): ['Edge-Loc', 'Loc', 'Center', 'Scratch', 'Random']
Edge-Loc_7413.jpg:	class id(s): [4, 2, 0, 6, 5], score(s): [0.71, 0.23, 0.07, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Center', 'Scratch', 'Random']
Edge-Ring_12619.jpg:	class id(s): [3, 0, 1, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Center', 'Donut', 'Edge-Loc', 'Random']
Edge-Ring_12668.jpg:	class id(s): [3, 1, 5, 0, 2], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Donut', 'Random', 'Center', 'Edge-Loc']
Edge-Ring_12709.jpg:	class id(s): [3, 2, 5, 0, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Random', 'Center', 'Scratch']
Edge-Ring_12712.jpg:	class id(s): [3, 0, 6, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Center', 'Scratch', 'Edge-Loc', 'Random']
Edge-Ring_12713.jpg:	class id(s): [3, 1, 5, 2, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Donut', 'Random', 'Edge-Loc', 'Scratch']
Edge-Ring_14164.jpg:	class id(s): [3, 5, 6, 0, 2], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Random', 'Scratch', 'Center', 'Edge-Loc']
Edge-Ring_20649.jpg:	class id(s): [3, 2, 6, 4, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Scratch', 'Loc', 'Random']
Edge-Ring_20826.jpg:	class id(s): [3, 2, 6, 4, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Scratch', 'Loc', 'Random']
Edge-Ring_20829.jpg:	class id(s): [3, 2, 6, 4, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Scratch', 'Loc', 'Random']
Edge-Ring_8409.jpg:	class id(s): [3, 2, 5, 7, 4], score(s): [0.88, 0.12, 0.00, 0.00, 0.00], label_name(s): ['Edge-Ring', 'Edge-Loc', 'Random', 'Near-full', 'Loc']
Loc_107555.jpg:	class id(s): [4, 2, 1, 0, 3], score(s): [0.93, 0.07, 0.00, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Donut', 'Center', 'Edge-Ring']
Loc_107665.jpg:	class id(s): [4, 0, 2, 6, 1], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Loc', 'Center', 'Edge-Loc', 'Scratch', 'Donut']
Loc_37961.jpg:	class id(s): [4, 2, 0, 5, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Center', 'Random', 'Scratch']
Loc_40.jpg:	class id(s): [4, 0, 2, 1, 5], score(s): [0.78, 0.13, 0.08, 0.00, 0.00], label_name(s): ['Loc', 'Center', 'Edge-Loc', 'Donut', 'Random']
Loc_40462.jpg:	class id(s): [4, 0, 2, 6, 1], score(s): [0.99, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Loc', 'Center', 'Edge-Loc', 'Scratch', 'Donut']
Loc_66389.jpg:	class id(s): [4, 1, 6, 2, 5], score(s): [0.65, 0.33, 0.03, 0.00, 0.00], label_name(s): ['Loc', 'Donut', 'Scratch', 'Edge-Loc', 'Random']
Loc_66672.jpg:	class id(s): [4, 2, 0, 1, 5], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Center', 'Donut', 'Random']
Loc_87260.jpg:	class id(s): [4, 2, 1, 0, 6], score(s): [0.97, 0.02, 0.01, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Donut', 'Center', 'Scratch']
Loc_87266.jpg:	class id(s): [1, 4, 2, 0, 5], score(s): [0.58, 0.41, 0.01, 0.00, 0.00], label_name(s): ['Donut', 'Loc', 'Edge-Loc', 'Center', 'Random']
Loc_94941.jpg:	class id(s): [4, 2, 1, 0, 5], score(s): [0.57, 0.29, 0.10, 0.04, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Donut', 'Center', 'Random']
Near-full_250273.jpg:	class id(s): [7, 2, 5, 4, 1], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Near-full', 'Edge-Loc', 'Random', 'Loc', 'Donut']
Near-full_714300.jpg:	class id(s): [5, 7, 2, 4, 1], score(s): [0.82, 0.18, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Near-full', 'Edge-Loc', 'Loc', 'Donut']
Near-full_733946.jpg:	class id(s): [7, 2, 5, 4, 3], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Near-full', 'Edge-Loc', 'Random', 'Loc', 'Edge-Ring']
Near-full_762971.jpg:	class id(s): [7, 1, 5, 2, 4], score(s): [0.65, 0.21, 0.11, 0.03, 0.00], label_name(s): ['Near-full', 'Donut', 'Random', 'Edge-Loc', 'Loc']
Near-full_809157.jpg:	class id(s): [7, 2, 5, 4, 1], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Near-full', 'Edge-Loc', 'Random', 'Loc', 'Donut']
Random_178268.jpg:	class id(s): [5, 1, 2, 3, 7], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Donut', 'Edge-Loc', 'Edge-Ring', 'Near-full']
Random_19120.jpg:	class id(s): [5, 7, 2, 1, 4], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Near-full', 'Edge-Loc', 'Donut', 'Loc']
Random_19201.jpg:	class id(s): [5, 2, 1, 7, 0], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Edge-Loc', 'Donut', 'Near-full', 'Center']
Random_19203.jpg:	class id(s): [5, 1, 2, 7, 0], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Donut', 'Edge-Loc', 'Near-full', 'Center']
Random_19287.jpg:	class id(s): [5, 7, 2, 1, 4], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Near-full', 'Edge-Loc', 'Donut', 'Loc']
Random_19414.jpg:	class id(s): [5, 7, 2, 1, 4], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Near-full', 'Edge-Loc', 'Donut', 'Loc']
Random_219919.jpg:	class id(s): [5, 1, 2, 7, 6], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Donut', 'Edge-Loc', 'Near-full', 'Scratch']
Random_219922.jpg:	class id(s): [5, 2, 1, 7, 0], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Edge-Loc', 'Donut', 'Near-full', 'Center']
Random_243242.jpg:	class id(s): [5, 1, 2, 7, 0], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Donut', 'Edge-Loc', 'Near-full', 'Center']
Random_243261.jpg:	class id(s): [5, 1, 7, 2, 0], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Donut', 'Near-full', 'Edge-Loc', 'Center']
Random_4788.jpg:	class id(s): [5, 2, 7, 1, 4], score(s): [0.99, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Random', 'Edge-Loc', 'Near-full', 'Donut', 'Loc']
Scratch_150649.jpg:	class id(s): [6, 1, 4, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Donut', 'Loc', 'Edge-Loc', 'Random']
Scratch_164102.jpg:	class id(s): [6, 1, 5, 2, 4], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Donut', 'Random', 'Edge-Loc', 'Loc']
Scratch_174933.jpg:	class id(s): [6, 1, 4, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Donut', 'Loc', 'Edge-Loc', 'Random']
Scratch_177754.jpg:	class id(s): [6, 4, 2, 0, 1], score(s): [0.99, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Loc', 'Edge-Loc', 'Center', 'Donut']
Scratch_23516.jpg:	class id(s): [6, 1, 5, 2, 4], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Donut', 'Random', 'Edge-Loc', 'Loc']
Scratch_270947.jpg:	class id(s): [6, 1, 4, 0, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Donut', 'Loc', 'Center', 'Random']
Scratch_283006.jpg:	class id(s): [6, 4, 1, 2, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Loc', 'Donut', 'Edge-Loc', 'Random']
Scratch_302544.jpg:	class id(s): [6, 4, 2, 1, 5], score(s): [1.00, 0.00, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Loc', 'Edge-Loc', 'Donut', 'Random']
Scratch_355662.jpg:	class id(s): [4, 2, 6, 1, 5], score(s): [0.95, 0.03, 0.01, 0.00, 0.00], label_name(s): ['Loc', 'Edge-Loc', 'Scratch', 'Donut', 'Random']
Scratch_366023.jpg:	class id(s): [6, 4, 2, 1, 5], score(s): [0.99, 0.01, 0.00, 0.00, 0.00], label_name(s): ['Scratch', 'Loc', 'Edge-Loc', 'Donut', 'Random']
  • 此处可以对照文件名和推理的结果来判断预测是否正确,对于ResNet模型,可以统计出75张图片,有5张预测错误
  • 下面会将预测错误的图片可视化,用于后期寻找原因,进行改进

9.2 使用MobileNet推理

注意此处将inference_cls.yaml复制一份并更改为inference_cls_mobilenetv3.yaml,
同时将该文件内的模型的位置更改成MobileNet的位置, 即:
inference_model_dir: “/home/aistudio/PaddleClas/deploy/models/MobileNetV3_large_x0_75”

%cd /home/aistudio/PaddleClas/deploy
!python python/predict_cls.py \
     -c configs/inference_cls_mobilenetv3.yaml
/home/aistudio/PaddleClas/deploy
2022-12-02 11:14:18 INFO: Loading faiss with AVX2 support.
2022-12-02 11:14:18 INFO: Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")
2022-12-02 11:14:18 INFO: Loading faiss.
2022-12-02 11:14:18 INFO: Successfully loaded faiss.
2022-12-02 11:14:18 INFO: 
===========================================================
==        PaddleClas is powered by PaddlePaddle !        ==
===========================================================
==                                                       ==
==   For more info please go to the following website.   ==
==                                                       ==
==       https://github.com/PaddlePaddle/PaddleClas      ==
===========================================================

2022-12-02 11:14:18 INFO: Global : 
2022-12-02 11:14:18 INFO:     batch_size : 1
2022-12-02 11:14:18 INFO:     cpu_num_threads : 10
2022-12-02 11:14:18 INFO:     enable_benchmark : True
2022-12-02 11:14:18 INFO:     enable_mkldnn : True
2022-12-02 11:14:18 INFO:     enable_profile : False
2022-12-02 11:14:18 INFO:     gpu_mem : 8000
2022-12-02 11:14:18 INFO:     infer_imgs : /home/aistudio/work/wafer_img/dataset/test
2022-12-02 11:14:18 INFO:     inference_model_dir : /home/aistudio/PaddleClas/deploy/models/MobileNetV3_large_x0_75
2022-12-02 11:14:18 INFO:     ir_optim : True
2022-12-02 11:14:18 INFO:     use_fp16 : False
2022-12-02 11:14:18 INFO:     use_gpu : True
2022-12-02 11:14:18 INFO:     use_tensorrt : False
2022-12-02 11:14:18 INFO: PostProcess : 
2022-12-02 11:14:18 INFO:     SavePreLabel : 
2022-12-02 11:14:18 INFO:         save_dir : ./pre_label/
2022-12-02 11:14:18 INFO:     Topk : 
2022-12-02 11:14:18 INFO:         class_id_map_file : /home/aistudio/work/wafer_img/dataset/label_list.txt
2022-12-02 11:14:18 INFO:         topk : 1
2022-12-02 11:14:18 INFO:     main_indicator : Topk
2022-12-02 11:14:18 INFO: PreProcess : 
2022-12-02 11:14:18 INFO:     transform_ops : 
2022-12-02 11:14:18 INFO:         ResizeImage : 
2022-12-02 11:14:18 INFO:             resize_short : 256
2022-12-02 11:14:18 INFO:         CropImage : 
2022-12-02 11:14:18 INFO:             size : 224
2022-12-02 11:14:18 INFO:         NormalizeImage : 
2022-12-02 11:14:18 INFO:             channel_num : 3
2022-12-02 11:14:18 INFO:             mean : [0.485, 0.456, 0.406]
2022-12-02 11:14:18 INFO:             order : 
2022-12-02 11:14:18 INFO:             scale : 0.00392157
2022-12-02 11:14:18 INFO:             std : [0.229, 0.224, 0.225]
2022-12-02 11:14:18 INFO:         ToCHWImage : None
Center_119628.jpg:	class id(s): [0], score(s): [0.92], label_name(s): ['Center']
Center_119714.jpg:	class id(s): [0], score(s): [0.92], label_name(s): ['Center']
Center_187048.jpg:	class id(s): [0], score(s): [0.91], label_name(s): ['Center']
Center_190340.jpg:	class id(s): [0], score(s): [0.93], label_name(s): ['Center']
Center_202124.jpg:	class id(s): [0], score(s): [0.93], label_name(s): ['Center']
Center_49.jpg:	class id(s): [0], score(s): [0.90], label_name(s): ['Center']
Center_7290.jpg:	class id(s): [0], score(s): [0.62], label_name(s): ['Center']
Center_83419.jpg:	class id(s): [0], score(s): [0.72], label_name(s): ['Center']
Center_85238.jpg:	class id(s): [0], score(s): [0.91], label_name(s): ['Center']
Center_96002.jpg:	class id(s): [0], score(s): [0.92], label_name(s): ['Center']
Donut_116252.jpg:	class id(s): [1], score(s): [0.92], label_name(s): ['Donut']
Donut_244230.jpg:	class id(s): [1], score(s): [0.86], label_name(s): ['Donut']
Donut_278979.jpg:	class id(s): [1], score(s): [0.89], label_name(s): ['Donut']
Donut_279135.jpg:	class id(s): [1], score(s): [0.89], label_name(s): ['Donut']
Donut_279770.jpg:	class id(s): [1], score(s): [0.88], label_name(s): ['Donut']
Donut_279845.jpg:	class id(s): [1], score(s): [0.87], label_name(s): ['Donut']
Donut_680504.jpg:	class id(s): [1], score(s): [0.91], label_name(s): ['Donut']
Donut_683294.jpg:	class id(s): [1], score(s): [0.91], label_name(s): ['Donut']
Donut_7334.jpg:	class id(s): [5], score(s): [0.69], label_name(s): ['Random']
Donut_7936.jpg:	class id(s): [1], score(s): [0.86], label_name(s): ['Donut']
Edge-Loc_24967.jpg:	class id(s): [2], score(s): [0.92], label_name(s): ['Edge-Loc']
Edge-Loc_29429.jpg:	class id(s): [2], score(s): [0.92], label_name(s): ['Edge-Loc']
Edge-Loc_36.jpg:	class id(s): [2], score(s): [0.79], label_name(s): ['Edge-Loc']
Edge-Loc_41932.jpg:	class id(s): [2], score(s): [0.85], label_name(s): ['Edge-Loc']
Edge-Loc_45091.jpg:	class id(s): [2], score(s): [0.92], label_name(s): ['Edge-Loc']
Edge-Loc_48272.jpg:	class id(s): [4], score(s): [0.49], label_name(s): ['Loc']
Edge-Loc_54178.jpg:	class id(s): [2], score(s): [0.93], label_name(s): ['Edge-Loc']
Edge-Loc_58508.jpg:	class id(s): [2], score(s): [0.61], label_name(s): ['Edge-Loc']
Edge-Loc_7369.jpg:	class id(s): [2], score(s): [0.91], label_name(s): ['Edge-Loc']
Edge-Loc_7413.jpg:	class id(s): [2], score(s): [0.62], label_name(s): ['Edge-Loc']
Edge-Ring_12619.jpg:	class id(s): [3], score(s): [0.92], label_name(s): ['Edge-Ring']
Edge-Ring_12668.jpg:	class id(s): [3], score(s): [0.92], label_name(s): ['Edge-Ring']
Edge-Ring_12709.jpg:	class id(s): [3], score(s): [0.92], label_name(s): ['Edge-Ring']
Edge-Ring_12712.jpg:	class id(s): [3], score(s): [0.92], label_name(s): ['Edge-Ring']
Edge-Ring_12713.jpg:	class id(s): [3], score(s): [0.77], label_name(s): ['Edge-Ring']
Edge-Ring_14164.jpg:	class id(s): [3], score(s): [0.91], label_name(s): ['Edge-Ring']
Edge-Ring_20649.jpg:	class id(s): [3], score(s): [0.92], label_name(s): ['Edge-Ring']
Edge-Ring_20826.jpg:	class id(s): [3], score(s): [0.93], label_name(s): ['Edge-Ring']
Edge-Ring_20829.jpg:	class id(s): [3], score(s): [0.93], label_name(s): ['Edge-Ring']
Edge-Ring_8409.jpg:	class id(s): [3], score(s): [0.90], label_name(s): ['Edge-Ring']
Loc_107555.jpg:	class id(s): [4], score(s): [0.83], label_name(s): ['Loc']
Loc_107665.jpg:	class id(s): [4], score(s): [0.92], label_name(s): ['Loc']
Loc_37961.jpg:	class id(s): [4], score(s): [0.91], label_name(s): ['Loc']
Loc_40.jpg:	class id(s): [4], score(s): [0.80], label_name(s): ['Loc']
Loc_40462.jpg:	class id(s): [4], score(s): [0.92], label_name(s): ['Loc']
Loc_66389.jpg:	class id(s): [4], score(s): [0.64], label_name(s): ['Loc']
Loc_66672.jpg:	class id(s): [4], score(s): [0.88], label_name(s): ['Loc']
Loc_87260.jpg:	class id(s): [4], score(s): [0.87], label_name(s): ['Loc']
Loc_87266.jpg:	class id(s): [4], score(s): [0.48], label_name(s): ['Loc']
Loc_94941.jpg:	class id(s): [1], score(s): [0.85], label_name(s): ['Donut']
Near-full_250273.jpg:	class id(s): [7], score(s): [0.87], label_name(s): ['Near-full']
Near-full_714300.jpg:	class id(s): [7], score(s): [0.71], label_name(s): ['Near-full']
Near-full_733946.jpg:	class id(s): [7], score(s): [0.90], label_name(s): ['Near-full']
Near-full_762971.jpg:	class id(s): [7], score(s): [0.79], label_name(s): ['Near-full']
Near-full_809157.jpg:	class id(s): [7], score(s): [0.90], label_name(s): ['Near-full']
Random_178268.jpg:	class id(s): [5], score(s): [0.90], label_name(s): ['Random']
Random_19120.jpg:	class id(s): [5], score(s): [0.92], label_name(s): ['Random']
Random_19201.jpg:	class id(s): [5], score(s): [0.92], label_name(s): ['Random']
Random_19203.jpg:	class id(s): [5], score(s): [0.92], label_name(s): ['Random']
Random_19287.jpg:	class id(s): [5], score(s): [0.91], label_name(s): ['Random']
Random_19414.jpg:	class id(s): [5], score(s): [0.92], label_name(s): ['Random']
Random_219919.jpg:	class id(s): [5], score(s): [0.90], label_name(s): ['Random']
Random_219922.jpg:	class id(s): [5], score(s): [0.92], label_name(s): ['Random']
Random_243242.jpg:	class id(s): [5], score(s): [0.93], label_name(s): ['Random']
Random_243261.jpg:	class id(s): [5], score(s): [0.63], label_name(s): ['Random']
Random_4788.jpg:	class id(s): [5], score(s): [0.91], label_name(s): ['Random']
Scratch_150649.jpg:	class id(s): [6], score(s): [0.91], label_name(s): ['Scratch']
Scratch_164102.jpg:	class id(s): [6], score(s): [0.88], label_name(s): ['Scratch']
Scratch_174933.jpg:	class id(s): [6], score(s): [0.91], label_name(s): ['Scratch']
Scratch_177754.jpg:	class id(s): [6], score(s): [0.90], label_name(s): ['Scratch']
Scratch_23516.jpg:	class id(s): [6], score(s): [0.58], label_name(s): ['Scratch']
Scratch_270947.jpg:	class id(s): [6], score(s): [0.91], label_name(s): ['Scratch']
Scratch_283006.jpg:	class id(s): [6], score(s): [0.90], label_name(s): ['Scratch']
Scratch_302544.jpg:	class id(s): [6], score(s): [0.89], label_name(s): ['Scratch']
Scratch_355662.jpg:	class id(s): [6], score(s): [0.39], label_name(s): ['Scratch']
Scratch_366023.jpg:	class id(s): [6], score(s): [0.90], label_name(s): ['Scratch']

class id(s): [6], score(s): [0.90], label_name(s): [‘Scratch’]
Scratch_302544.jpg: class id(s): [6], score(s): [0.89], label_name(s): [‘Scratch’]
Scratch_355662.jpg: class id(s): [6], score(s): [0.39], label_name(s): [‘Scratch’]
Scratch_366023.jpg: class id(s): [6], score(s): [0.90], label_name(s): [‘Scratch’]

  • 仅有3张图片分错, Test_Acc达到 96%, 这个在进一步改进即可上线demo!

10. 推理结果处理以及可视化

10.1 Resnet错误结果可视化分析

此处主要是将分类错误的图片单独拿出来分析,直观的分析错误的原因,便于改进。

import os
import pandas as pd
import cv2
import matplotlib.pyplot as plt
%matplotlib inline

img_root = "/home/aistudio/work/test"
wrong_list = ['Edge-Loc_48272.jpg', 'Edge-Loc_58508.jpg', 'Edge-Loc_7413.jpg', 'Loc_87266.jpg', 'Scratch_355662.jpg']
wrong_label = ['Loc','Edge-Ring','Loc','Donut','Loc']

plt.figure(figsize = (15,6))
for i in range(len(wrong_list)):
    img_path = os.path.join(img_root, wrong_list[i])
    img = cv2.imread(img_path)
    plt.subplot(1,len(wrong_list), i+1)
    plt.imshow(img[:,:, ::-1])
    plt.xlabel(wrong_list[i])
    # plt.axis('off')
    plt.title("Predict Result: " + wrong_label[i], fontsize = 12)

在这里插入图片描述

10.2. MobileNet分类可视化分析

wrong_list = ['Donut_7334.jpg', 'Edge-Loc_48272.jpg', 'Loc_94941.jpg']
wrong_label = ['Random','Loc','Donut']

plt.figure(figsize = (15,6))
for i in range(3):
    img_path = os.path.join(img_root, wrong_list[i])
    img = cv2.imread(img_path)
    plt.subplot(1,3, i+1)
    plt.imshow(img[:,:, ::-1])
    plt.xlabel(wrong_list[i])
    # plt.axis('off')
    plt.title("Predict Result: " + wrong_label[i], fontsize = 12)

在这里插入图片描述

  • 通过比较,可以发现分类错误的图谱大部分是Loc, Edge-Loc等图片
  • 这种现象与晶圆图谱分类的特殊性有关,与普通的图片分类不同,晶圆图谱的失效模式类别和区域位置强相关,例如同样是loc失效,在中间为center类别,在边缘为Edge-Loc类别,在其他位置为Loc,这个和图片分类中的位置不变性相矛盾
  • 对此,后期可以通过增加相应类别的样本数量来达到一定的改善

11: 总结

本项目主要是介绍如何在半导体制造中引入深度学习技术解决问题。
半导体制造作为高端制造业,其整个产业链的安全非常重要。特别是最近几年,国产之路诸多方面遭到某些制裁和限制,因而将整个产业链国产化迫在眉睫。
本项目展示使用飞桨的图像识别套件来快速解决问题,希望能在此领域抛砖引玉,希望更多的小伙伴能挖掘更多的应用,一起助力半导体智能制造!大国崛起,吾辈自强!

  • 关于作者:
    • wolfmax老狼,飞桨领航团无锡团团长, AICA六期学员
    • 某半导体CIM软件集成商图像算法工程师,主要方向为图像相关相关的检测分割等算法开发
    • 我在AI Studio上获得钻石等级,点亮6个徽章,来互关呀~ https://aistudio.baidu.com/aistudio/personalcenter/thirdview/801106
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值