# US 12,602,768 B2 · Surface defect detection model training method, and surface defect detection method and system

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

- Number: US 12,602,768 B2
- Document ID: US12602768B2
- Status: Granted
- Kind: B2
- Application number: 18/283,372
- Filed: 2022-05-17
- Published: 2024-05-23
- Granted: 2026-04-14
- Earliest claimed: 2021-05-19
- Assignees: Opt Machine Vision Tech Co., Ltd.
- Applicants: Opt Machine Vision Tech Co., Ltd.
- Inventors: Hongchao Gao; Shenglin Lu
- Web page: https://patentgrep.com/patent/US12602768B2

## CPC

- G06T 7/0004: {Industrial image inspection}
- G06T 7/0008: {checking presence/absence}
- G06T 7/00: Image analysis
- G06V 10/44: Local feature extraction by analysis of parts of the pattern, e.g. by detecting edges, contours, loops, corners, strokes or intersections; Connectivity analysis, e.g. of connected components
- G06V 10/761: {Proximity, similarity or dissimilarity measures}
- G06V 10/771: Feature selection, e.g. selecting representative features from a multi-dimensional feature space
- G06V 10/82: using neural networks
- G06V 20/52: Surveillance or monitoring of activities, e.g. for recognising suspicious objects (recognising microscopic objects G06V20/69)
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06V 2201/06: Recognition of objects for industrial automation
- Y02P 90/30: Computing systems specially adapted for manufacturing
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06V: IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- Y02P: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS

## Abstract

A method for training a surface defect detection model as well as a method and a system for detecting a surface defect are provided. The method and the system for detecting a surface defect adopt the trained surface defect detection model. The method for training a surface defect detection model includes acquiring a normal image of a product and an external image that is irrelevant to the product and inputting the normal image and the external image into a deep neural network-based surface defect detection model, and training the deep neural network-based surface defect detection model to obtain the trained surface defect detection model. The normal image represents the product surface of no defect on this surface.

## Claims

### Claim 1

A method for training a surface defect detection model, comprising:
acquiring a first image and a second image, wherein the first image corresponds to an image of a product; and
inputting the first image and the second image into a deep neural network-based surface defect detection model and training the deep neural network-based surface defect detection model to obtain the trained surface defect detection model;
wherein the loss function corresponding to a training process is expressed as:
loss
i
=
1
W
×
H
⁢
(
∑
i
=
1
,
j
=
1
W
,
H
⁢
(
1
-
Y
i
)
⁢
(
1
-
exp
⁡
(
-
F
i
,
j
)
)
+
∑
i
=
1
,
j
=
1
W
,
H
⁢
(
Y
i
)
⁢
(
F
i
,
j
)
)
;
wherein lossi denotes the loss function, W denotes a width of the distance matrix, H denotes a height of the distance matrix, Yi denotes a tag of an i-th image, Yi=1 represents a first image, Yi=0 represents an image not satisfying a predetermined threshold requirement, Fi, j denotes a value at a position (i, j) in the distance matrix.

### Claim 2 (depends on 1)

The method for training a surface defect detection model according to claim 1, wherein the inputting the first image and the second image into the deep neural network-based surface defect detection model and training the deep neural network-based surface defect detection model to obtain the trained surface defect detection model comprises:
inputting the first image and the second image into the deep neural network-based surface defect detection model;
performing feature extraction on the first image utilizing the deep neural network-based surface defect detection model to obtain a feature map of the first image, performing the feature extraction on the second image utilizing the deep neural network-based surface defect detection model to obtain a feature map of the second image, mapping the feature map of the first image to obtain a distance matrix of the first image, and mapping the feature map of the second image to obtain a distance matrix of the second image;
setting a loss function based on the distance matrix of the first image and the distance matrix of the second image; and
training the deep neural network-based surface defect detection model utilizing the loss function, to obtain the trained surface defect detection model.

### Claim 3 (depends on 1)

A method for detecting a surface defect, wherein the method is performed by utilizing the surface defect detection model trained with the method according to claim 1, and the method comprises:
capturing an image of a to-be-examined target product; and
inputting the captured image of the target product into the surface defect detection model to perform defect detection on a surface of the target product; and locating, if a defect is detected, the detected defect.

### Claim 4 (depends on 3)

The method for detecting surface defect according to claim 3, wherein the inputting the captured image of the target product into the surface defect detection model to perform defect detection on the surface of the target product comprises:
inputting the captured image of the target product into the surface defect detection model;
performing feature extraction on the image of the target product through the surface defect detection model, to obtain a feature map F_w,h,c of the image of the target product;
mapping the feature map F about the target product to obtain a distance matrix Di,j=∥Fw,h,:∥2 about the target product;
mapping the feature map F about the target product to obtain a distance D=Σw,h∥Fw,h,:∥2/W×H from the target product to a normal product;
determining whether a distance median about the target product is within a preset range;
determining that there is no defect on the surface of the target product if it is determined that the distance median about the target product is within the preset range; and
determining that there is a defect on the surface of the target product and locating the detected defect if it is determined that the distance median about the target product is not within the preset range.

### Claim 5 (depends on 4)

The method for detecting a surface defect according to claim 4, wherein the locating the detected defect comprises:
locating the detected defect based on the distance matrix;
determining, for each position <i, j> in the distance matrix about the target product, whether a distance value at the position <i, j> is within the preset range;
determining that the detected defect is not in an image block corresponding to the position <i, j> on the surface of the target product if it is determined that the distance value at the position <i, j> is within the preset range; and
determining that the detected defect is in the image block corresponding to the position <i, j> on the surface of the target product if it is determined that the distance value at the position <i, j> is not within the preset range.
