# US 2024/0005469 A1 · Defect detection method and apparatus

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0005469 A1
- Document ID: US20240005469A1
- Status: Published application
- Kind: A1
- Application number: 18/129,819
- Filed: 2023-03-31
- Published: 2024-01-04
- Earliest claimed: 2022-06-30
- Assignees: Contemporary Amperex Technology Co., Limited
- Applicants: Contemporary Amperex Technology Co., Limited
- Inventors: Guannan Jiang; Annan Shu; Qiangwei Huang
- Web page: https://patentgrep.com/patent/US20240005469A1

## CPC

- G06T 7/0002: {Inspection of images, e.g. flaw detection}
- G06T 7/0004: {Industrial image inspection}
- G06N 3/045: Combinations of networks
- G06N 3/096: Transfer learning
- G06T 7/11: Region-based segmentation
- G06T 7/136: involving thresholding
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Embodiments of this application provide a defect detection method and apparatus. The method includes: obtaining an image for inspection; performing anomaly detection on the image for inspection to obtain an anomaly region image corresponding to the image for inspection; and performing defect classification on the anomaly region image to obtain defect detection information of the image for inspection. The defect detection method of the embodiments of this application is divided into two steps of anomaly detection and defect classification. Anomaly detection is performed on the image for inspection first, and then defect classification needs to be performed only on an anomaly region, reducing the workload of defect classification, thereby improving the efficiency of defect detection.

## Claims

### Claim 1

A defect detection method, comprising:
obtaining an image for inspection;
performing anomaly detection on the image for inspection to obtain an anomaly region image corresponding to the image for inspection; and
performing defect classification on the anomaly region image to obtain defect detection information of the image for inspection.

### Claim 2 (depends on 1)

The defect detection method according to claim 1, wherein the defect detection information comprises defect type information and defect location information of the anomaly region image.

### Claim 3 (depends on 1)

The defect detection method according to claim 1, wherein the performing anomaly detection on the image for inspection to obtain an anomaly region image corresponding to the image for inspection comprises:
obtaining, based on an anomaly detection model, a difference image used to represent an anomaly region; and
segmenting the difference image based on a segmentation threshold to obtain the anomaly region image.

### Claim 4 (depends on 3)

The defect detection method according to claim 3, wherein the anomaly detection model comprises a pre-trained teacher network and a student network distilled from the teacher network; and
the obtaining, based on an anomaly detection model, a difference image used to represent an anomaly region comprises:
inputting the image for inspection into both the teacher network and the student network so as to obtain a feature image output by the teacher network and a feature image output by the student network; and
calculating a difference between each pixel of the feature image output by the teacher network and each pixel of the feature image output by the student network to obtain the difference image.

### Claim 5 (depends on 3)

The defect detection method according to claim 3, wherein the segmenting the difference image based on a segmentation threshold to obtain the anomaly region image comprises:
taking pixels higher than the segmentation threshold in the difference image as anomaly pixels and remaining pixels as normal pixels, so as to obtain the anomaly region image.

### Claim 6 (depends on 4)

The defect detection method according to claim 4, wherein before the performing anomaly detection on the image for inspection, the method further comprises:
training the student network of the anomaly detection model.

### Claim 7 (depends on 6)

The defect detection method according to claim 6, wherein the training the student network comprises:
initializing the student network;
inputting normal images into the teacher network and the student network to obtain feature images of all layers output by the teacher network and feature images corresponding to all layers output by the student network;
minimizing differences between the feature images of all layers output by the teacher network and the feature images corresponding to all layers output by the student network in a distillation loss function; and
updating parameters of the student network based on loss calculation results.

### Claim 8 (depends on 4)

The defect detection method according to claim 4, wherein the method further comprises:
calculating an optimal anomaly determining threshold of the anomaly detection model; and
setting the segmentation threshold based on the optimal anomaly determining threshold.

### Claim 9 (depends on 8)

The defect detection method according to claim 8, wherein the calculating an optimal anomaly determining threshold of the anomaly detection model comprises:
inputting a test sample into both the teacher network and the student network, wherein the test sample is a defective image or a normal image;
determining a maximum value in difference images between the feature images output by the teacher network and the feature images output by the student network as an anomaly value of the test sample;
under the condition that the anomaly value is greater than the anomaly determining threshold, determining that the test sample is a defective image, otherwise, determining that the test sample is a normal image; and
calculating a difference between a false positive rate and a true positive rate corresponding to each anomaly determining threshold in the anomaly detection model, and determining an anomaly determining threshold corresponding to a maximum difference as the optimal anomaly determining threshold; wherein
the false positive rate is a percentage of test samples that are incorrectly determined as a defective image, and the true positive rate is a percentage of test samples that are correctly determined as a defective image.

### Claim 10 (depends on 8)

The defect detection method according to claim 8, wherein the setting the segmentation threshold based on the optimal anomaly determining threshold comprises:
setting the segmentation threshold to be less than the optimal anomaly determining threshold.

### Claim 11 (depends on 1)

The defect detection method according to claim 1, wherein before the performing defect classification on the anomaly region image, the method further comprises:
obtaining one or more rectangular images comprising anomaly pixels from the anomaly region image; wherein
the performing defect classification on the anomaly region image comprises:
performing defect classification on the one or more rectangular images.

### Claim 12 (depends on 11)

The defect detection method according to claim 11, wherein the performing defect classification on the one or more rectangular images comprises:
classifying the rectangular image(s) by using a defect classification model.

### Claim 13 (depends on 12)

The defect detection method according to claim 12, wherein the classifying the rectangular image(s) by using a defect classification model comprises:
obtaining a feature vector of the rectangular image(s);
calculating a similarity score of the rectangular image(s) for each known defect type based on the feature vector; and
performing defect classification on the rectangular image(s) based on the similarity score.

### Claim 14 (depends on 13)

The defect detection method according to claim 13, wherein the obtaining a feature vector of the rectangular image(s) comprises:
extracting the feature vector of the rectangular image(s) by using a ResNet network model.

### Claim 15 (depends on 13)

The defect detection method according to claim 13, wherein the calculating a similarity score of the rectangular image(s) for each known defect type based on the feature vector comprises:
mapping the feature vector to a trained feature vector space, wherein the feature vector space comprises a feature vector for the known defect type; and
calculating a distance between the feature vector and the feature vector for the known defect type, so as to obtain the similarity score of the rectangular image(s) for each known defect type.

### Claim 16 (depends on 13)

The defect detection method according to claim 13, wherein the performing classification on the rectangular image(s) based on the similarity score comprises:
under the condition that a maximum similarity score of the similarity scores is not lower than a first similarity threshold, outputting a defect type corresponding to the maximum similarity score; or
under the condition that the similarity scores are all lower than a first similarity threshold, outputting an unknown defect type.

### Claim 17 (depends on 16)

The defect detection method according to claim 16, wherein before the outputting a defect type corresponding to the maximum similarity score, the method further comprises:
under the condition that the defect type is a specified defect type, calculating area of the anomaly pixels in the rectangular image; wherein
the outputting a defect type corresponding to the maximum similarity score comprises:
under the condition that the area is greater than an area threshold, outputting the defect type corresponding to the maximum similarity score.

### Claim 18 (depends on 16)

The defect detection method according to claim 16, wherein the outputting a defect type corresponding to the maximum similarity score comprises:
under the condition that the maximum similarity score is higher than a second similarity threshold, outputting the defect type corresponding to the maximum similarity score, wherein the second similarity threshold is greater than the first similarity threshold.

### Claim 19 (depends on 2)

The defect detection method according to claim 2, wherein the defect detection information further comprises a similarity score corresponding to a defect type.
