# US 12,770,246 B2 · Defect detecting apparatus and method

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

- Number: US 12,770,246 B2
- Document ID: US12770246B2
- Status: Granted
- Kind: B2
- Application number: 18/330,381
- Filed: 2023-06-07
- Published: 2023-12-07
- Granted: 2026-10-20
- Earliest claimed: 2022-06-07
- Assignees: Hon Hai Precision Industry Co., Ltd.; Foxconn Technology Group Co., Ltd.
- Applicants: Hon Hai Precision Industry Co., Ltd.; Foxconn Technology Group Co., Ltd.
- Inventors: Yung-Hui Li; Kai-Lin Yang; Yi-Rong Lin
- Web page: https://patentgrep.com/patent/US12770246B2

## CPC

- G06T 7/001: {using an image reference approach}
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL

## Abstract

A defect detecting apparatus and method are provided. The defect detecting apparatus receives an image to be tested. The defect detecting apparatus detects the image to be tested through a defect detecting model to generate an anomaly score corresponding to the image to be tested, and the defect detecting model is generated based on the training of a generative adversarial network and a plurality of normalized loss functions. The defect detecting apparatus compares the anomaly score with an anomaly score threshold to determine whether the image to be tested is a defective image.

## Claims

### Claim 1

A defect detecting apparatus, comprising:
a storage, being configured to store a defect detecting model;
a transceiver interface; and
a processor, being electrically connected to the storage and the transceiver interface, and being configured to perform operations comprising:
receiving an image to be tested from the transceiver interface;
detecting the image to be tested received from the transceiver interface through the defect detecting model stored in the storage to generate an anomaly score corresponding to the image to be tested, wherein the defect detecting model is generated based on a training of a generative adversarial network and a plurality of normalized loss functions, wherein the anomaly score is generated by calculating a pixel squared difference between the image to be tested and a reconstructed image corresponding to the image to be tested; and
comparing the anomaly score with an anomaly score threshold to determine whether the image to be tested is an image depicting a defective object;
wherein the processor is further configured to perform the following operations:
receiving a plurality of sample images;
inputting the sample images to a training model constructed by the generative adversarial network;
training the training model based on an encoder loss function, a contextual loss function, and an adversarial loss function after normalization, wherein the encoder loss function, the contextual loss function, and the adversarial loss function are individually normalized, and a value range of each of the normalized loss functions is constrained between 0 and 1; and
setting the training model after training as the defect detecting model.

### Claim 2 (depends on 1)

The defect detecting apparatus of claim 1, wherein the reconstructed image corresponding to the image to be tested is generated by a first encoder and a decoder in the defect detecting model.

### Claim 3 (depends on 1)

The defect detecting apparatus of claim 1, wherein the encoder loss function after normalization is generated based on a normalized squared difference between a first encoding feature and a second encoding feature, and the first encoding feature is generated by a first encoder in the defect detecting model, and the second encoding feature is generated by a second encoder in the defect detecting model.

### Claim 4 (depends on 1)

The defect detecting apparatus of claim 1, wherein the contextual loss function after normalization is generated based on a absolute value of a normalized pixel difference between the image to be tested and the reconstructed image corresponding to the image to be tested, wherein the reconstructed image corresponding to the image to be tested is generated by a first encoder and a decoder in the defect detecting model.

### Claim 5 (depends on 1)

The defect detecting apparatus of claim 1, wherein the adversarial loss function after normalization is generated based on a normalized feature matching squared difference.

### Claim 6 (depends on 1)

The defect detecting apparatus of claim 1, wherein the image to be tested corresponds to a first color space, and the processor further performs following operations:
converting the image to be tested to a second color space, wherein the second color space comprises at least one first channel value and a plurality of second channel values; and
performing a normalization operation on the at least one first channel value of the image to be tested in the second color space.

### Claim 7 (depends on 6)

The defect detecting apparatus of claim 6, wherein a first range corresponding to the at least one first channel value is different from a second range corresponding to the second channel values.

### Claim 8 (depends on 1)

The defect detecting apparatus of claim 1, wherein the processor further performs the following operations:
receiving the plurality of sample images, wherein the sample images correspond to a first color space;
converting the sample images to a second color space, wherein the second color space comprises at least one first channel value and a plurality of second channel values;
performing a normalization operation on the at least one first channel value of the sample images in the second color space;
inputting the sample images to the training model constructed by the generative adversarial network;
training the training model based on the encoder loss function, the contextual loss function, and the adversarial loss function after normalization; and
setting the training model after training as the defect detecting model.

### Claim 9 (depends on 8)

The defect detecting apparatus of claim 8, wherein a first range corresponding to the at least one first channel value is different from a second range corresponding to the second channel values.

### Claim 10

A defect detecting method, being adapted for use in an electronic apparatus, and comprising following steps:
receiving an image to be tested;
detecting the image to be tested through a defect detecting model to generate an anomaly score corresponding to the image to be tested, wherein the defect detecting model is generated based on a training of a generative adversarial network and a plurality of normalized loss functions, wherein the anomaly score is generated by calculating a pixel squared difference between the image to be tested and a reconstructed image corresponding to the image to be tested; and
comparing the anomaly score with an anomaly score threshold to determine whether the image to be tested is an image depicting a defective object;
wherein the defect detecting method further comprises the following steps:
receiving a plurality of sample images;
inputting the sample images to a training model constructed by the generative adversarial network;
training the training model based on an encoder loss function, a contextual loss function, and an adversarial loss function after normalization, wherein the encoder loss function, the contextual loss function, and the adversarial loss function are individually normalized, and a value range of each of the normalized loss functions is constrained between 0 and 1; and
setting the training model after training as the defect detecting model.

### Claim 11 (depends on 10)

The defect detecting method of claim 10, wherein the reconstructed image corresponding to the image to be tested is generated by a first encoder and a decoder in the defect detecting model.

### Claim 12 (depends on 10)

The defect detecting method of claim 10, wherein the encoder loss function after normalization is generated based on a normalized squared difference between a first encoding feature and a second encoding feature, and the first encoding feature is generated by a first encoder in the defect detecting model, and the second encoding feature is generated by a second encoder in the defect detecting model.

### Claim 13 (depends on 10)

The defect detecting method of claim 10, wherein the contextual loss function after normalization is generated based on a absolute value of a normalized pixel difference between the image to be tested and the reconstructed image corresponding to the image to be tested, wherein the reconstructed image corresponding to the image to be tested is generated by a first encoder and a decoder in the defect detecting model.

### Claim 14 (depends on 10)

The defect detecting method of claim 10, wherein the adversarial loss function after normalization is generated based on a normalized feature matching squared difference.

### Claim 15 (depends on 10)

The defect detecting method of claim 10, wherein the image to be tested corresponds to a first color space, and the defect detecting method further comprises following operations:
converting the image to be tested to a second color space, wherein the second color space comprises at least one first channel value and a plurality of second channel values; and
performing a normalization operation on the at least one first channel value of the image to be tested in the second color space.

### Claim 16 (depends on 15)

The defect detecting method of claim 15, wherein a first range corresponding to the at least one first channel value is different from a second range corresponding to the second channel values.

### Claim 17 (depends on 10)

The defect detecting method of claim 10, further comprising the following steps:
receiving the plurality of sample images, wherein the sample images correspond to a first color space;
converting the sample images to a second color space, wherein the second color space comprises at least one first channel value and a plurality of second channel values;
performing a normalization operation on the at least one first channel value of the sample images in the second color space;
inputting the sample images to the training model constructed by the generative adversarial network;
training the training model based on the encoder loss function, the contextual loss function, and the adversarial loss function after normalization; and
setting the training model after training as the defect detecting model.

### Claim 18 (depends on 17)

The defect detecting method of claim 17, wherein a first range corresponding to the at least one first channel value is different from a second range corresponding to the second channel values.
