automated optical inspection and defect detection€¦ · across frameworks model design and tuning...

53
Automated Optical Inspection and Defect Detection with Deep Learning Harshita Bhurat Product Manager Image Processing and Computer Vision

Upload: others

Post on 12-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Automated Optical Inspection and Defect

Detection with Deep Learning

Harshita Bhurat

Product Manager – Image Processing and Computer Vision

Page 2: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

What is Automated Optical Inspection?

“ Automated optical inspection is the image-based or visual

inspection of manufacturing parts where a camera scans

the device under test for both failures and quality defects"

3

Machine Vision Visual Inspection

Automated Inspection

Automated Defect Detection

Page 3: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Automatic Defect Detection

Defect Detection in Railway Components

Visual Inspection of Automotive Parts

Pipe

Assess Pipe Weld Damage at Power Plants

Customer References

4

Page 4: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

5

Page 5: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Can you find the defective hex nut?

6

Page 6: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

7

Page 7: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

8

Page 8: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

9

Page 9: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Finding Defective Hex Nuts

10

Page 10: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Detecting Parts

11

Page 11: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

12

Defect Detection Workflow

Ground truth labeling

DATA PREPARATION

Data access and preprocessing

Simulation-based data generation

I Iteration and Refinement

AI MODELING

Model exchange across frameworks

Model design andtuning

Hardware-accelerated training

DEPLOYMENT

Edge, cloud, desktop

Enterprise Systems

Embedded Devices

Ground truth labeling

12

Page 12: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

13

Defect Detection Workflow

Ground truth labeling

DATA PREPARATION

Data access and preprocessing

Simulation-based data generation

I Iteration and Refinement

AI MODELING

Model exchange across frameworks

Model design andtuning

Hardware-accelerated training

DEPLOYMENT

Edge, cloud, desktop

Enterprise Systems

Embedded Devices

Ground truth labeling

13

Page 13: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

14

How do I access large data that might not fit in memory?

How do I preprocess data and get the right features?

How do I label my data faster?

What if I have an imbalanced dataset or don’t have enough data?

Page 14: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

How do I access large data that might not fit in memory?

15

Page 15: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

How do I load and access large amounts of data?

Loads image/signal data

into memory as and

when needed

Work with out-of-

memory numeric data

– Train deep neural

networks for

numeric arrays

>> imageDatastore

>> audioDatastore

>> fileDatastore

Custom Datastores also

available

Datastores Tall Arrays

Work with very large, tiled and

multi-resolution images

BigImage

Each red box is a 1024-by-1024 tile in the file.L1's dimensions = 29,600 x 46,000L2's dimensions = 14,800 x 23,000L3's dimensions = 7,500 x 12,000Rows = 29600Columns = 46000TileSizeIntrinsic = [1024 1024]ResolutionLevelSizes = [29600 46000

14800 230007500

12000]CoarsestLevel = 3FinestLevel = 1PixelSpacings = [1 1; 2 2; 3.947 3.833]

16

Page 16: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

17

How do I preprocess data and get the right features?

Page 17: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

18

How do I preprocess data and get the right features?

Page 18: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Pre-processing Data – Registration Estimator App

19

Page 19: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Pre-processing Data – Image Segmenter App

20

Page 20: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Preprocessing Data - Apps

21

Color Thresholder Image Region Analyzer

Page 21: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Pre-processing Data – Built-in Algorithms

imgaborfilt fibermetricimadjust

22

Page 22: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Without pre-processing With pre-processing

Defect detection using AlexNet: Results with preprocessing

Peak of normal score shifts right(Sufficient margin from

abnormal units)

Without pre-processing

score

nu

m o

f el

emen

ts

Histogram of predicted scores

With pre-processing

score

Separated defective units clearly

23

Page 23: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

24

How do I label my data faster?

Page 24: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Preprocessing - Labeling

25

Page 25: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Image & Video Labeler

Image Labeler

+ Video labeler

Big-Image

Labeler

26

Page 26: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Big Image Labeler

Image Labeler

+ Video labeler

Big-Image

Labeler

27

Page 27: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Access and Preprocessing – Common Challenges

What if I have an imbalanced dataset or don’t have enough data?

28

Page 28: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Contrast Jitter on Grayscale

Data Augmentation by Transformation

Original

Dataset

Augmented

Dataset

N times as

much data

29

Page 29: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Data Augmentation : Generative Adversarial Networks (GANs)

Generative Adversarial Networks

30

Page 30: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

31

Defect Detection Workflow

Ground truth labeling

DATA PREPARATION

Data access and preprocessing

Simulation-based data generation

I Iteration and Refinement

AI MODELING

Model exchange across frameworks

Model design andtuning

Hardware-accelerated training

DEPLOYMENT

Edge, cloud, desktop

Enterprise Systems

Embedded Devices

Ground truth labeling

31

Page 31: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deep Learning for Defect Detection

32

Deep learning for Classification

Deep Learning for Object Detection

Page 32: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deep Learning for Defect Detection – Multiple techniques

33

Deep learning for Classification

Page 33: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Two Approaches for Deep Learning

2. Fine-tune a pre-trained model (transfer learning)

1. Train a deep neural network from scratch

34

Page 34: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Train a Deep Neural Network from Scratch

35

Page 35: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Convolution +

ReLu PoolingInput

Convolution +

ReLu Pooling

Feature Learning

Fully

ConnectedSoftmax

cartruck

bicycle

van

… …

Classification

Two approaches for Deep learning

Fully

Connected Softmaxfood

tree

New Classification

Approach 2. Fine-tune a pre-trained model (Transfer learning)

36

Page 36: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Fine-tune a Pre-trained Model (Transfer Learning)

37

Page 37: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Classification with Trained MobileNetV2

38

Page 39: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Classified as “keyboard” due to

the presence of the mouse

Incorrectly classified “coffee

mug” as “buckle” due to the

watch

Class Activation Mapping to Investigate Network Predictions

40

Page 40: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Visualization of Features with CAM

OK → Reacts to whole surface

Bad→ Reacts to the scratch

Captured Image Classification and CAM

41

Page 41: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deep Learning for Defect Detection

42

Deep Learning for Object Detection

Page 42: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Detecting Objects with You Only Look Once (YOLO) v2

Predictions

YOLO

CNN

NetworkDecode

Predictions

Build, test, and deploy a deep learning solution that can detect objects in images and video

43

Page 43: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Mask Detection with YOLO v2

44

Page 44: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Experiment Manager

45

Page 45: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Defect Detection Workflow

Ground truth labeling

DATA PREPARATION

Data access and preprocessing

Simulation-based data generation

I Iteration and Refinement

AI MODELING

Model exchange across frameworks

Model design andtuning

Hardware-accelerated training

DEPLOYMENT

Edge, cloud, desktop

Enterprise Systems

Embedded Devices

Ground truth labeling

46

Page 46: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deploy to Any Processor with Best-in-class Performance

FPGA

CPU

GPUCode

Generation

47

Page 47: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deploy defect detection algorithms from

MATLAB to Jetson AGX XavierDeploy defect detection algorithms from

MATLAB to ZCU102 board from Xilinx

Deploy to Hardware

48

Page 48: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deploy to Hardware

Resources:

▪ Deploying Deep Neural Networks to GPUs and

CPUs Using MATLAB Coder and GPU Coder

▪ Using GPU Coder to Prototype and Deploy on

NVIDIA Drive, Jetson

▪ Real-Time Object Detection with YOLO v2 Using

GPU Coder

▪ Image Classification on ARM CPU: SqueezeNet

on Raspberry Pi

▪ Deep Learning on an Intel Processor with MKL-

DNNDefect detection deployed on

ARM Cortex-A microprocessor

49

Page 49: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Deploy to Enterprise IT Infrastructure

Request

Broker

MATLAB

Production Server

Custom Tools

Streaming

Dashboards

Databases

Cloud Storage

Containers

Cloud & Datacenter

Infrastructure

50

Page 50: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Defect Detection Workflow

Ground truth labeling

DATA PREPARATION

Data access and preprocessing

Simulation-based data generation

I Iteration and Refinement

AI MODELING

Model exchange across frameworks

Model design andtuning

Hardware-accelerated training

DEPLOYMENT

Edge, cloud, desktop

Enterprise Systems

Embedded Devices

Ground truth labeling

51

Page 51: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

Key Takeaways

▪ Interactive and easy to use apps help explore, iterate and automate

workflows

▪ Flexibility and options to choose networks and optimizations based on

data and requirements

▪ MATLAB provides an easy and extensible framework for defect

detection from data access to deployment

Page 52: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing
Page 53: Automated Optical Inspection and Defect Detection€¦ · across frameworks Model design and tuning Hardware-accelerated training DEPLOYMENT Edge, cloud, ... Data Access and Preprocessing

THANK YOU!

54