0% found this document useful (0 votes)
4 views33 pages

Chapter 4

This chapter discusses the detection of defects in printed circuit boards (PCBs) using a novel deep learning approach that integrates attention-based pretrained models for improved feature learning. It highlights the limitations of manual inspection and proposes an optimized DenseNet-121 model combined with a gated recurrent unit (GRU) for enhanced defect classification. The methodology includes preprocessing techniques, dataset balancing using KM-SMOTE, and feature extraction to improve the accuracy of PCB defect detection.

Uploaded by

Geetha Daniel M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views33 pages

Chapter 4

This chapter discusses the detection of defects in printed circuit boards (PCBs) using a novel deep learning approach that integrates attention-based pretrained models for improved feature learning. It highlights the limitations of manual inspection and proposes an optimized DenseNet-121 model combined with a gated recurrent unit (GRU) for enhanced defect classification. The methodology includes preprocessing techniques, dataset balancing using KM-SMOTE, and feature extraction to improve the accuracy of PCB defect detection.

Uploaded by

Geetha Daniel M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

94

CHAPTER 4

DETECTION OF PRINTED CIRCUIT BOARDS DEFECTS USING


NOVEL DEEP LEARNING WITH ATTENTION-BASED
PRETRAINED MODEL FOR FEATURE LEARNING

4.1 INTRODUCTION

The PCB is a crucial component of all electrical devices, whether used


in homes or businesses. Numerous defects, such as scratches, holes, cracks,
broken edges, missing components, or misalignment, can arise at various phases
of the PCB manufacturing process. The manual visual inspection is carried out to
identify these defects. On the other hand, it is subjective, slow, and variable, and
thus does not meet current manufacturing standards. The limitations of manual
inspection become more evident as technology develops and PCBs become more
complex. Regardless of skill level, the human eye is prone to errors and loses
effectiveness when confronted with complex patterns, small parts, and crowded
boards. The PCB quality control industry is undergoing a paradigm change toward
automation as a result of the requirement for a more reliable and effective
inspection system. The rapid development of deep learning algorithms has
enabled effective identification of real and pseudo-defects in PCBs when
sufficient annotated data are available. Its ability to automatically capture intricate
patterns from big datasets makes PCB defect identification more precise and
effective. RNNs have been widely used in various applications and have
95

demonstrated considerable promise in handling sequential data. The capacity of


RNNs to identify patterns in defect data has led to a notable increase in interest in
PCB defect detection over the past few years. Numerous RNN variants, including
LSTM, Bidirectional Bi-LSTM, and GRUs, have been employed in the
identification of PCB defects to solve the vanishing gradients problem and
enhance efficiency. The GRU network has demonstrated exceptional prowess
compared to others. Defect manifestation often follows patterns that develop over
time, making them a good candidate for PCB defect identification. In addition,
unlike others, GRU is mostly preferred due to its computational efficiency,
simpler architecture, and faster training time. Building on these advantages, this
chapter proposes an optimized DenseNet-121 that incorporates spatial-channel
attention into its structure for enhanced spatial feature learning, along with an
optimized GRU model for defect classification.

4.2 METHODOLOGY

The difficulty of PCB defect detection lies in the fact that the area of
the minor defect and the defect characteristics are not apparent without enlarging
the picture; that is, it is difficult to be extracted by the classifier, and serious missed
detection exists, which cannot meet the practical requirements of the production
inspection link. To overcome the difficulties posed by small targets and restricted
features, this chapter proposes an attention-inclusive DenseNet121 with a
hyperparameter-tuned GRU network to enhance feature extraction and classify
defects in PCBs. The working architecture of the proposed PCB defect detection
in the system is shown in Figure 4.1. The preprocessing stage utilizes CLAHE for
image contrast enhancement and AMF for noise rejection on the raw PCB dataset
to enhance image quality. The KM-SMOTE is used in the data balancing block to
address the limitations imposed by data class imbalance and data scarcity.
The system introduces the SCDSNT121 in the feature extraction block to capture
the features of the balanced PCB dataset. Finally, the ROGRU is developed to
96

classify the six types of defect classes, where the SCRSO algorithm optimizes the
hyperparameters, including learning rate, epochs, weights, and bias, to reduce the
classification loss. The following sections provide a brief explanation of these
phases. Figure 4.1 shows the Workflow of the proposed ROGRU approach and
Table 4.1 shows the deign and functionality of the proposed pipeline stages.

Figure 4.1 Workflow of the proposed ROGRU approach

Table 4.1 Design and functionality of the proposed pipeline stages


Algorithm Network
Pipeline stage Model used Justification
type structure
Enhances local contrast
Preprocessing CLAHE(Contrast Tile based
and removes the
(Image Limited AHE) histogram with
Enhancement + impulse noise while
Enhancement+ +AMF clip limit & used
Spatial filtering preserving edges
Noise (Adaptive Median variable window
,improving feature
Filtering) Filter) median filter
extraction
Generates
KM-SMOTE
K-means representative synthetic
(K-Means based
Data clustering+ samples ,reduces class
Synthetic Minority Data Balancing
Augmentation SMOTE within overlap and improves
Oversampling
clusters genalization on
Technique)
imbalnced datasets
97

Table 4.1 Continued


Achieves rich
SCDSNT121
multiscale feature
(Spatial and Deep CNN DesseNet 121
learning with reduced
Feature Channel Attention feature connectivity with
parameters and
Extraction based extractor multi scale fusion
computation, suitable
DenseNet121)
for real time systems
ROGRU
(Reptile
optimized GRU cells with Captures long and short
Gated regularization term dependencies
Deep sequential
Classification Recurrent Unit) (e.g dropout/L2) while reducing
learning and Meta
and Model + SCSRO (Sine and optimized overfitting and provides
heuristic
optimization Chaotic and gates,population global optimization of
optimization
Cauchy based search with weights/
Mutation based chaotic maps hyperparameters
Reptile Search
Optimization)

4.2.1 Preprocessing

Initially, the system collects defect data from the publicly available
Deep PCB database. Then, the preprocessing step takes place, which is essential
for improving the quality of PCB images and ensuring that the deep learning
model effectively learns defect patterns. Preparing and converting original data
into a suitable format for the training methods is part of it. The preprocessing
pipeline consists of two steps designed to standardize the dataset, enhance image
features, and optimize model performance. The first step is to improve contrast to
achieve a clear vision of the image. The next step involves noise filtering to
remove unwanted noise from the PCB image.
98

[Link] Contrast enhancement

Contrast enhancement is a simple image processing technique that


raises the dynamic range of pixel intensities in an image to improve contrast.
This technique aims to enhance the clarity and brightness of an image, making it
appear clearer and more vibrant. This, in turn, helps improve accuracy and makes
defects more easily identifiable for classification. The contrast of the collected
PCB images is enhanced using the CLAHE method. It is a well-known technique
in image preprocessing that enhances contrast by adjusting the image histograms
in specific areas. A significant contrast between defects is necessary for proper
classification in PCB imaging, where CLAHE has been shown to enhance image
clarity. It offers advantages over traditional AHE. While AHE enhances local
contrast by computing multiple histograms, each associated with a specific section
of an image, and redistributing luminance values accordingly, it often
overamplifies noise in relatively uniform regions. CLAHE addresses this issue by
limiting the histogram amplification, thereby preserving image clarity while
preventing noise over enhancement. This makes CLAHE especially suitable for
enhancing edge definition and local contrast without introducing excessive noise.
The CLAHE approach separates an input image into non-overlapping contextual
sections, referred to as sub-images, tiles, or blocks. The Block Size and Clip Limit
parameters define the CLAHE. These two parameters estimate image quality more
accurately. The algorithmic process of CLAHE is explained as follows:
Input: Color images captured using a high-resolution camera.
Output: Enhanced image with improved local contrast.
Step 1: Examine the PCB image that was sent.
Step 2: The RGB image in two dimensions is transformed into a
grayscale image. The range of each color pixel in R, G, and B is
[0, 255]. A grayscale image is produced when all the three-color
pixels are integrated and have the same pixel value at the same
positions.
99

Step 3: Divide the input grayscale image into multiple non-overlapping


contextual regions called tiles (e.g., 8x8 or 16x16). Each tile is
processed independently to enhance local contrast.
Step 4: For each tile, compute the histogram based on the inherent
intensity level. The histogram illustrates the frequency of each
intensity value in the tile.
Step 5: Obtain the histogram for each region, then apply the threshold to
cut it. The CLAHE algorithm limits contrast amplification by
calculating the CDF and then clipping the histogram with a
specified clip limit. This prevents over-enhancement and reduces
noise amplification. It also restricts the transformation function’s
slope, ensuring more natural contrast improvement.
Step 6: After redistributing the clipped pixel values among all histogram
bins, reallocate the pixel values to their original positions. It helps
maintain local brightness and improves contrast uniformly across
the image.
Step 7: Apply bilinear interpolation to combine the histograms of all the
tiles to get the final Histogram.
Step 8: Repeat steps 4 to 7 for all tiles in the image.
Step 9: Merge all the processed tiles to reconstruct the final enhanced
image.

[Link] Noise filtering

A camera or computer vision may have captured the original images,


which may include unrelated information, noise, or artifacts. Such noisy data may
compromise the defect identification ability of the model. A blurry image or
imprecise details would make it difficult to distinguish between a mouse bite and
an open circuit. This study uses the AMF method to denoise the PCB image.
Unlike a traditional median filtering algorithm, the AMF algorithm dynamically
100

adjusts the size of the filtering window for each pixelto effectively differentiate
between noise and valid structural patterns on the PCB surface. AMF operates in
two phases: first, it estimates the kernel’s middle value; second, it determines
whether the present pixel value is an impulse (salt and pepper noise). If the pixel
is detected as corrupted, it is replaced with the computed middle value; otherwise,
the original grayscale pixel value is retained. This adaptive mechanism helps
effectively remove noise while preserving critical edge and texture details in the
PCB image. The working process is briefly explained as follows:

Initially, for each pixel NFab , a local neighborhood is considered. If the


pixel value exceeds the window’s current maximum threshold, it is directly
replaced by the median value, i.e., NFab  NFmedian . Otherwise, the algorithm

computes the top value NFmx , middle value NFmedian , and bottom value NFmi in the

filtering window. If the condition NFmx  NFmedian  NFmi holds, it indicates that the
window contains a mix of corrupted and uncorrupted pixels, and the algorithm

proceeds to evaluate the central pixel. When the pixel satisfies NFmx  NFab  Bmi ,
the filtering window is adaptively expanded to improve detection sensitivity.
If not, the pixel is assumed to be corrupted and replaced with the median value of
the surrounding pixels. This iterative process continues until a suitable window
size is found or all impulse noise is removed. Through this adaptive mechanism,
the AMF not only eliminates high-density noise but also preserves fine-grained
defect features, which are critical for accurate PCB defect classification.

4.2.2 Dataset Balancing

Dataset balancing refers to addressing situations in which the


distribution of examples across classes is uneven. This imbalance often leads to
the majority class being well-educated, while the minority class is barely learned,
if at all. Studies conducted on imbalanced datasets may yield good results during
the training phase, but often fail to generalize when exposed to new data from the
101

minority class. The KM-SMOTE method is employed to balance the dataset and
address this issue. SMOTE is an oversampling method that balances the original
training dataset. The synthetic sample generation is the central concept of the
SMOTE approach, instead of iterating over minority class samples. These samples
are made particularly to replicate the properties of raw data. However, SMOTE
randomly synthesizes minority instances along the line segments connecting
minority samples and their selected nearest neighbors, while ignoring nearby
instances of the majority class. This can lead to the generation of synthetic samples
in regions heavily populated by majority instances, which increases the risk of
misclassification. So, the system first applies the K-means clustering algorithm to
group the minority instances within the dataset. Oversampling is then performed
separately within each cluster. This clustering-based approach mitigates the issue
of SMOTE ignoring nearby majority instances by localizing the oversampling
process. As a result, KM-SMOTE enhances the representation of minority classes,
improving the classifier’s performance and generalization ability. The process
involved in the KM-SMOTE is explained as follows:
Let PBS  PB1 , PB2 , PB3 ,......PBN  be the set of samples in the
pre-processed PCB defect dataset, where each sample belongs to either the
majority class (non-defective) or the minority class (defective). Then, group only
the minority class samples from PBS to form a new subset PBMin . Then, apply the

K-means clustering algorithm to new subset PBMin  to divide the minority class

samples into k clusters C1 , C2 ,.......Ck . For each minority sample PBi  PBMin ,

compute the Euclidean distance to each centroid and assign PBi to the nearest
cluster. It is defined as in Equation (4.1).

EUD   PB i  Cj 2 (4.1)

where, PBi indicates the minority sample and C j denotes the centroid of the cluster

j . Then, recalculate cluster centroids based on current assignments and reassign


102

points until convergence. Then, a new minority sample can be created by filtering
clusters with fewer minority classes and choosing clusters with more minority
classes. Next, perform SMOTE oversampling on each filtered cluster. In this
method, interpolation is used between a selected sample from the minority class
PBi and one of its closest neighbours k to produce new synthetic samples PBnew ,
which is calculated using Equation (4.2):
PBnew  PBm   PBz  PBm  (4.2)

where,  indicates an arbitrary number between 0 and 1, PBnew refers to a recently

created sample of minority classes, PBm denotes an arbitrarily chosen minority


class from the filtered cluster’s k nearest neighbours, and PBz denotes all the
negative samples of the filtered clusters except k neighbours. The SMOTE
approach enhances minority class representation in the dataset by generating
additional synthetic samples until the desired balance is achieved.

4.2.3 Feature Extraction

The following procedure involves extraction, where meaningful


characteristics are filtered from the preprocessed image to capture the object's
shape and texture for PCB classification. This study develops the SCDSNT121
algorithm to extract features for accurate PCB classification automatically.
DenseNet121 (DSNT-121) is a CNN network renowned for its efficient use of
parameters and enhanced gradient flow during training, which helps to identify
the PCB image’s minor defects. Compared with standard CNNs, every layer in
DSNT-121 is feed-forward to every other layer, where each layer only connects
to the layer behind it. This means that the output of each layer is forwarded to all
subsequent layers. This connectivity enables enhanced features, gradient flow, and
reuse, which can relieve the vanishing gradient issue while training deeper
networks. DSNT-121 is introduced with a total of 121 layers, comprising four
blocks. Between each block, a transition layer is inserted, which utilizes
103

downsampling on feature maps. Individual blocks consist of several convolutional


layers connected in a series. While DSNT-121 has shown strong performance in
PCB image analysis, it often struggles to effectively capture the full spectrum of
spatial and contextual information in PCB imaging. To overcome these
challenges, the system employs the Spatial and Channel Attention (SCA)
mechanism. By dynamically focusing on the most relevant features at different
scales and across varying spatial contexts, spatial and channel attention
mechanisms enable the network to extract both global and local patterns, thereby
improving the model's ability to discriminate between subtle differences in defect
characteristics. Figure 4.2 illustrates the architecture diagram of the proposed
SCDSNT121 method.

Figure 4.2 SCDSNT121 architecture

The DSNT-121 architecture receives an RGB image of


224 × 224 pixels, which serves as the basis for the introduced model.
The ImageNet dataset was utilized to train the weights, collecting sufficient
information to improve the fully connected layer’s weights as output. It begins
with a fundamental convolution and pooling layer. In the DSNT-121 network, the
Stem layer’s convolutional layer has a 7×7 size, three padding, and a single
convolutional kernel. The convolutional kernel slides over the input PCB images
104

to capture prominent features, such as textures, edges, and corners, allowing the
network to identify key patterns and providing an output in the form of a feature
map. The convolution layer also has a stride of 2, which essentially means that the
kernel moves 2 pixels at a time, skipping some regions of the input PCB image to
assist in reducing the dimensions, a process known as downsampling. This allows
for lower computational costs and prevents overfitting. The convolution process
is equated as in Equation (4.3),
~
 
LCEu   u . f R  u 1  AC (4.3)
u ~
where, LCE refers to the convolutional layer’s output feature maps,  u is the u th

-layer neuron status,  u and AC represents the weight matrix and bias from

u 1th to R
the u th , and f represents the ReLU activation function, which is
followed directly by the pooling layer. The pooling window padding, stride, and
size are 1, 2, and 3×3, respectively. The model’s capability to extract local features
of the image is impacted by the pooling window size, which estimates the number
of features pooled within each window. By following this layer, there is a four
dense block layer. Regardless of the number of filters, each Dense block has a
fixed feature map dimension. In DenseNet, it helps to minimize the feature map
size and make down-sampling easier. Two convolutions, with 1x1 and 3x3
estimated pieces, are present in each dense block. This is done multiple times in
both dense blocks 1 and 2, 24 and 16 times in dense blocks 3 and 4, respectively.
Then, the input of each layer is forwarded to the next layer. As a result, all feature
maps from earlier layers are sent to the u th layer. The outputs can be written as
shown in Equation (4.4):
DNL  FNCu DN0 , DN1, , , , , , , , DNu 1  (4.4)

where, DN0 , DN1 , , , , , , , , DNu 1  signifies the joining process of feature-maps

created in each dense layer 0,1,...., u  1 and FN Cu . shows that the u th layer’s
input of three successive operations, such as BN, ReLU, and Conv. BN is used to
accelerate training and facilitate learning by employing higher learning rates.
105

The transition layer, located between two dense blocks, is essential because it
improves the number of feature maps as they progress through the dense blocks,
which can make them costly and memory-intensive. A batch normalization layer,
a 1 × 1 convolutional, and a 2 × 2 max pooling layer make up each transition layer.
Max pooling is used to detect important characteristics, such as edges, and
efficiently reduce feature dimensionality. After that, the feature maps from the last
dense block are passed to the SCA attention mechanism that focuses on spatial
H W C
and channel dependencies in the PCB image. Let DNL  R be the SCA
module’s input, where, H , W , and represent the feature map’s height, width, and
channel count, respectively. The aggregation operation receives the input feature
maps and aggregates them along their channel dimension to generate a channel
descriptor, which provides the global distribution of a spatial feature, which is
calculated using Equation (4.5):
   
ATSP  f R f 11 f R BN f 11 DNL  (4.5)

where, DN L indicates the final DenseNet layer’s output, f 11 indicates a


convolution operation using 1 × 1 filter, BN . refers to the batch normalization,

and f 
R
. represents the ReLU function. In addition, the aggregation operation
receives the input feature maps and aggregates them in their spatial dimension
H W to generate a channel descriptor, which provides the global distribution of
a channel feature, which is defined as in Equation (4.6):
H W

V m, n
1
ATCH  (4.6)
H W
S
m n

where, VS represents the S th channel’s spatial position. Then, the spatial  ATSP  and

channel features  ATCH  are fused by element-wise sum and fed into the GAP for
further processing. This pooling operation reduced the feature map’s spatial
dimensions into a single vector, thereby collecting global information. The final
feature vectors are passed to the classifier for further processing.
106

4.2.4 Classification

Finally, the ROGRU is utilized for classification, which categorizes six


types of PCB defects, including missing holes, mouse bites, open circuits, shorts,
spurs, and spurious copper, based on the extracted feature set. GRU, a special
type of RNN, has been developed to address the fundamental difficulties in
common RNNs using a specific infrastructure. Compared to other categories of
RNNs, the GRU facilitates the training with fewer parameters by using gating
mechanisms to control information flow. It is more efficient due to its primary
innovation. The aforementioned ability of the GRU is utilized for PCB defect
classification in our research study. The standard structure of the GRU is shown
in Figure 4.3. To enable the GRU model to automatically determine optimal
parameters during training, rather than relying on manual tuning, this work
employs an intelligent optimization approach called the SCRSO algorithm to
optimize the model's attributes effectively.

Figure 4.3 GRU structure

The operational principle of a GRU network is illustrated in


as follows: First, the update gate IU t  decides the amount of previously captured
data allocated for the next step. This mechanism effectively enables the GRU to
107

handle the long-term patterns without suffering from vanishing gradients. It is


defined as in Equation (4.7):
IU t   s WCIU Gt  PRIU t 1  BC IU  (4.7)

where, Gt represents the SCDSNT121 -extracted feature vector from the current

region of the PCB, t 1 denotes the output at the previous moment, WC and PR
denote the weight matrices, and BC denotes the bias parameter, respectively.
In addition,  s signifies the LReLU function, a type of activation function. It is
applied in neural networks to introduce nonlinearity to the outputs between layers,
and LReLU's simplicity and computational speed make it suitable for training
complex models, such as GRUs. It is defined as in Equation (4.8):
 s  max 0.01G , G  (4.8)
when, G refers to the positive input extracted feature maps, the Leaky ReLU
function returns G in the same way as the ReLU function. On the other hand, this
function returns a tiny negative value corresponding to the input when it G is
negative. Then, the input information Gt and the hidden state t 1 inherited from

the previous node estimate the reset gate IRt  , which is used to control the recall
or forgetfulness of the derived information from the previous step. The last time
step’s entire data will be transmitted to the next step if the reset gate yields a high
number; if not, almost all the information will be forgotten and will hardly enter
the next step. It is defined as in Equation (4.9):
IRt   s WCIR Gt  PRIR t 1  BC IR  (4.9)

~
 
After that, a candidate's hidden state M t is calculated from the reset
gate. This is used to determine the information stored from the past. It is
formulated as in Equation (4.10):
M t  tanh WC Gt  PR IRt . t 1   BC 
~
(4.10)
108

Then, the updated hidden state t  is calculated using the update gate
and the candidate hidden state using Equation (4.11):
t  1  IU t . t 1  IU t . M t
~
(4.11)

Finally, training to the GRU network’s final layer and moment


achieves the GRU model’s output value YFt , as shown in Equation (4.12)

YFt   s WCYF . t 1  (4.12)


where, WCYF indicates the weight matrix for output.

[Link] Hyperparameter tuning

To tune the hyperparameters optimally, the system develops the


SCRSO algorithm. The Reptile Search Optimization (RSO) algorithm is a
well-known swarm-based metaheuristic algorithm inspired by the hunting
behaviors of crocodiles, encompassing their encirclement strategies, hunting
tactics, and social dynamics. Crocodiles exhibit a diverse range of behaviors, with
a primary emphasis on encircling and capturing prey. These natural behaviors
provide the basis for the mathematical modeling of RSO, which, in turn, drives
optimization processes. This is because it has adequate execution time, an efficient
convergence rate, and greater effectiveness compared to other well-known
optimization algorithms. Despite its effectiveness, it is subject to certain
limitations, including getting trapped in local minima, decreased population
diversity, and slow convergence speed.

To overcome the problems of falling into local optima and premature


convergence, an enhanced RSO, called SCRSO, is proposed, which integrates a
sine chaotic mechanism, a Levy flight strategy, and a Cauchy mutation strategy.
The population is initialized utilizing the sine chaotic map, which improves the
diversity and well-distributed set of initial hyperparameter combinations.
The Levy flight strategy is applied to enhance the exploration capability of
109

RSO and to mitigate the issue of premature convergence. Finally, the Cauchy
mutation strategy is employed to improve the exploitation ability and prevent the
algorithm from becoming stuck in local optima. These strategies help
RSO efficiently search the hyperparameter space by maintaining a balance
between exploring new regions and exploiting the most promising solutions,
ultimately leading to the selection of optimal hyperparameter combinations for
improved classifier performance. The process involved in the proposed SCRSO is
explained as follows:
Initially, the optimization process begins by generating the initial
population of hyperparameters using the sine chaotic map, which is known for its
ability to produce non-repetitive, highly random, and stable sequences through the
nonlinear behavior of the sine function. Unlike traditional random or grid-based
methods, the sine chaotic map enhances the diversity of the search space in the
early stages of the optimization process. Its oscillatory and non-periodic
characteristics help avoid premature convergence by ensuring that the initial
population spans a broader and more varied region of the solution space.
It is formulated using Equation (4.13):

SRxc,d1   . sin  SRxc, d  (4.13)

where,  indicates the control parameter, which is between 0, 1/. The sine map

exhibits chaotic behaviour when  falls within the range of [0.87, 1]. Then, the
RSO method creates a Fitness Function (FF) to guide the selection of optimal
hyperparameters that produce superior classifier results. This function returns a
positive value to represent the performance quality of each candidate
hyperparameter set. During the tuning process, the minimization of classifier error
rate was supposed to be achieved by formulating FF in Equation (4.14).
FMIC
FF   100 (4.14)
FTN

where, FMIC indicates the count of wrongly classified classes and FTN refers to the
total instance count, respectively. After that, the global exploration phase of
110

RSO employs two leading operators, high walking and belly walking, which
facilitate the hunting phase and help identify areas with a high density of prey.
High walking and belly walking occur in the first and second half of the
exploration phase, respectively. Accordingly, the crocodile positions are updated
as demonstrated in Equation (4.15), allowing the algorithm to explore diverse
regions of the hyperparameter space and improve the chances of discovering
optimal hyperparameter configurations.

, d  H x , d  EC  RFx , d  Levy  ,
SRbest
c c c
c  Tc
c 1  4
SR 
, d  SRk 1, d  N  Levy  ,
x, d
SRbest
c c c Tc  c  2Tc
 4 4
(4.15)
c
where, SRbest, d is the d
 th
dimension of the fittest hyperparameter at c th iteration,

H xc, d indicates the hunting parameter for the d th dimension of the x th solution,

EC denotes a scalar constant tuned to 0.1, RFxc, d refers to a function whose value

is reduced to narrow the search landscape, SRkc1, d shows the d th dimension of the

k1th solution, k1 denotes the random scalar, N c represents an Evolutionary


Sense function returning random numbers in a range that decreases throughout
iteration, Tc denotes the maximum iterations, and Levy   refers to the Levy
flight mechanism strategy, respectively. The algorithm’s global search ability was
balanced by proposing the Levy flight mechanism. It is a type of random
walk in which the steps are drawn from a Levy distribution. It is defined as in
Equation (4.16):
k2
Levy    0.01  1 ~  (4.16)
k3

where, k 2 and k 3 represents two arbitrary numbers (0,1), ~ is usually 1.5, and 
refers to the constant value. During the exploitation phase, the RSO introduces
two discrete states that mirror the hunting behaviour of crocodiles: hunting
coordination and hunting cooperation. These states capitalize on crocodile
111

behaviours to efficiently search promising regions in the hyperparameter space,


utilizing distinctive reinforcement mechanisms that diverge from their
surroundings. As a result, the exploitation search procedure exhibits the capability
to uncover nearly optimal hyperparameter configurations through successive
attempts. It is mathematically defined as in Equation (4.17):
SR c
 best, d  DFx , d  Cauchy 0, 1
c 2 Tc  c  3Tc
c 1
 4 4
SR x, d (4.17)
SRbest 3Tc  c  Tc
, d  H x , d  m  RFx , d
c c c
 4

where, DFxc, d represents a difference in the percentage among the crocodiles in

the best location and the current location,  m indicates a small value, and

Cauchy 0, 1 refers to the Cauchy mutation function, respectively. In this, the

Cauchy mutation is added to the RSO is to enhance the search ability to jump out
of local optima. Another purpose is to improve exploitation capabilities in the
context of hunting and prevent the reptile population from becoming trapped in a
local optimum. The Cauchy mutation can produce various random variables that
are consistent with the Cauchy distribution, enhancing the reptile population's
search ability. After the exploitation phase, the proposed SCRSO process
terminates once the end criterion is satisfied. This occurs when the maximum
iteration is reached or the difference between two successive values of the
objective function, based on hyperparameter performance, is less than a
predefined threshold. This termination criterion ensures that the best-performing
hyperparameter configuration is selected without unnecessary computation.
Figure 4.4 illustrates the flowchart of the suggested SCRSO model.
112

Figure 4.4 Flowchart of the proposed SCRSO algorithm

4.3 PERFORMANCE EVALUATION

This section conducts the quantitative and qualitative experiments to


analyse the effectiveness of the proposed PCB defect classification using the
ROGRU model. The Windows 11 (64-bit) operating system was used for all trials
in this study, along with a high-performance computer configuration that included
an Intel Core i7-12700 CPU (12th Gen) and an NVIDIA GeForce RTX 3090 GPU
with 24 GB of dedicated memory. The system was equipped with 64 GB of
DDR4 RAM and a 2 TB NVMe SSD to ensure smooth data processing and rapid
model training. The proposed methods were implemented using the Python
programming language, and the development was carried out using the
TensorFlow and Keras libraries, along with other essential Python packages,
including NumPy, Pandas, OpenCV, Scikit-learn, and Matplotlib. Table 4.2 gives
the hyperparameters used in this study.
113

Table 4.2 List of hyperparameters


SI. No. Hyperparameters Values
1 Optimizer Adam
2 Activation ReLU, Leaky ReLU
3 Dropout rate 0.5
4 Batch size 32
5 Learning rate 0.001
6 Number of GRU units 128
7 Epochs 50

The evaluation is performed using the publicly available Kaggle


deep PCB defect dataset, which contains six types of defects: missing hole,
mouse bite, open circuit, short, spur, and spurious copper. Figure 4.5 shows
the overall classified results, where Figure 4.5(a) presents the sample images
taken from the input dataset. Figure 4.5(b) shows the preprocessed images
obtained after applying CLAHE and AMF. CLAHE enhances the local
contrast of the images, while AMF effectively removes impulse noise without
blurring essential details. This preprocessing improves image clarity and
feature visibility, thereby enhancing the effectiveness of the subsequent
classification process. Figure 4.5(c) displays the classified results after applying
the ROGRU model. Together, the preprocessing, SCDSNT121-based feature
learning, and classification steps significantly contribute to the improved
performance of the system.
114

(a)

(b)
115

(c)
Figure 4.5 Classified results of the ROGRU model (a) Input sample images,
(b) Preprocessed images, and (c) Final classified images

4.3.1 Analysis of the Proposed ROGRU Model

This section evaluates our recommended ROGRU model alongside


some popular deep learning models, including GRU, LSTM, DNN, and CNN
models. These baseline classifiers were specifically selected due to their ability to
capture complex patterns and high-level representations in PCB images.
These models provide a reliable foundation for demonstrating the effectiveness of
the proposed ROGRU model in detecting PCB defects. The evaluation is
performed by using some standard metrics such as accuracy, precision, recall,
F1-score, sensitivity, specificity, False Positive Rate (FPR), False Negative
Rate (FNR), False Rejection Rate (FRR), Negative Predictive Value (NPV),
and Matthew’s Correlation Coefficient (MCC), respectively. These metrics
evaluated the model’s ability to provide precise predictions and set parameters
for assessing its overall performance. Also, assisted in locating cases of
inaccurate forecasts.
116

Figure 4.6 Accuracy Vs. Epoch analysis of the proposed ROGRU model

Figure 4.7 Loss Vs. Epoch analysis of the proposed ROGRU model

The training and validation accuracy and loss values shown in


Figures 4.6 and 4.7 illustrate the performance of our model over multiple epochs,
ranging from 0 to 50. At epoch 0, both training and validation accuracies increase
steadily, and losses decrease steadily, indicating effective learning and
generalization. By Epoch 50, the model achieves a training accuracy of
99.78% and a validation accuracy of 99.12%. Additionally, the training and
validation losses are 0.011 and 0.019, respectively, indicating a minimal gap
117

between the two and suggesting that the proposed model generalizes well and
avoids overfitting. This is primarily achieved by incorporating KM-SMOTE to
generate new synthetic samples, rather than simply duplicating existing ones,
which helps reduce the risk of overfitting. Most importantly, the SCRSO-based
hyperparameter optimization ensures that the model is trained with the most
suitable configuration, balancing model complexity and generalization.
These components collectively contribute to achieving the best performance.

Table 4.3 Accuracy analysis of the proposed ROGRU and baseline models
Proposed GRU LSTM DNN CNN
Defects
(%) (%) (%) (%) (%)
Missing holes 99.45 96.78 95.98 93.48 92.79
Open circuit 99.37 96.62 95.78 93.33 92.58
Short 99.21 96.45 95.55 93.19 92.36
Spur 98.97 96.18 95.33 93.07 92.37
Spurious copper 98.74 96.03 95.11 92.91 92.05
Mouse bite 98.98 95.98 95.91 92.74 92.75
Average 99.12 96.34 95.61 93.12 92.45

Table 4.3 presents the results of the proposed and baseline models in
terms of the accuracy metric. For the missing holes defect, the existing models
yield accuracies of 96.78%, 95.98%, 93.48%, and 92.79%, which are lower
compared to our model, as our model achieves a high-level outcome of
99.45% accuracy. Similarly, for the remaining defects, such as open circuit, short,
spur, spurious copper, and mouse bite, the proposed model achieves
99.37%, 99.21%, 98.97%, 98.74%, and 98.98% accuracy. Thus, these findings
demonstrate that the suggested model outperforms existing models in terms of
overall efficiency and attains a decent classification result.
118

Figure 4.8 Precision performance evaluation of the proposed ROGRU model

Figure 4.9 Recall performance evaluation of the proposed ROGRU model

Figure 4.8 and 4.9 demonstrates the precision and recall evaluation of
the proposed ROGRU method. In this case, the existing DNN and CNN models
exhibit lower performance because they primarily focus on spatial features and
are unable to model temporal dependencies across sequential PCB image patterns.
Temporal information is critical in PCB defect detection, where the structural
continuity or progression of defect patterns across the image plays a key role.
As a result, the DNN and CNN models produce average precision scores of
92.86% and 91.97%, respectively, and recall scores of 92.83% and 91.95%.
119

Furthermore, GRU and LSTM models are more capable of learning temporal
patterns by modeling sequential dependencies, and thus outperform DNN and
CNN. However, they are limited in capturing spatial features, which are crucial
for accurately predicting defects. To address both these challenges, our model
incorporates the SCDSNT121 module, which effectively extracts spatial features
from PCB images, along with the ROGRU model, which captures temporal
dependencies across image regions. This combination results in significantly
improved efficiency, with a precision of 98.74% and a recall of 98.71%. Thus, it
validates the effectiveness of our model in accurately classifying PCB defects.

Table 4.4 F1-score analysis of the proposed ROGRU and baseline models
Defects Proposed GRU LSTM DNN CNN
(%) (%) (%) (%) (%)
Missing holes 99.27 95.88 94.58 93.11 92.15
Open circuit 99.14 95.7 94.36 92.96 92.03
Short 98.69 95.43 94.21 92.78 91.97
Spur 98.57 95.31 94.14 92.56 91.88
Spurious copper 98.36 95.27 93.93 92.39 92.28
Mouse bite 99.49 95.95 94.69 93.24 91.45
Average 98.92 95.59 94.32 92.64 91.96

Table 4.4 shows the proposed and existing methods’ results established
by the F1-score measurement. For example, the baseline methods obtained a
F1-score rate of approximately 91% to 96%, whereas the proposed method
achieved a notably higher score of 99%. Better performance can be attributed to
the hyperparameters being appropriately chosen with the use of SCRSO. On the
other hand, the proposed method outperformed the existing methods, which
included no optimization models for choosing the best parameters.
120

Table 4.5 Average outcomes analysis of the proposed ROGRU and existing
models
MCC NPV FPR FNR FRR
Techniques
(%) (%) (%) (%) (%)
Proposed 0.904 99.23 0.043 0.053 0.053
GRU 0.703 96.47 0.13 0.167 0.168
LSTM 0.540 95.78 0.174 0.286 0.286
DNN 0.462 93.34 0.234 0.364 0.364
CNN 0.616 92.68 0.297 0.211 0.211

The results of the suggested and traditional methods are shown in


Table 4.4 regarding MCC, NPV, FPR, FNR, and FRR measures, and achieves
best results of 0.904%, 99.23%, 0.043%, 0.053%, and 0.053%, accordingly.
The incorporation of KM-SMOTE and the SCRSO model avoids overfitting and
guarantees that it performs effectively when applied to fresh, unknown data.
Finally, ROGRU’s outstanding performance in correctly categorizing
PCB defects is a result of its optimized design and capacity to handle a variety of
defect characteristics. As such, it is an invaluable instrument for assuring quality
control and dependability in PCB manufacturing.

Figure 4.10 Training time analysis of the proposed ROGRU model


121

The comparison of training times for the suggested and existing


methods is shown in Figure 4.10. The proposed ROGRU model requires a training
time of 19.2 minutes, resulting in better outcomes than traditional methods, but
slightly higher than traditional GRU due to the additional time required for
hyperparameter tuning and enhanced feature extraction. However, it remains more
efficient than the conventional structure with improved accuracy of 99.12%.
This shows that our model achieves a favorable trade-off, delivering optimized
training without incurring substantial computational cost.

4.3.2 Testing Results

To evaluate how well the proposed model performs on unseen data, the
testing results are given in Table 4.6. In this, the proposed model achieves an
accuracy of 98.99%, 99.05% precision, 98.86% recall, and a 99.03% f1-score,
illustrating better performance than the traditional methods when applied to
unseen data, and also, the minimal gap between training and testing results shows
that model generalize well and avoid overfitting due to the integration of
KM-SMOTE-based dataset balancing with better feature learning ability.

Table 4.6 Testing outcomes of the proposed and existing models


Test Test Test recall Test f1-score
Techniques
accuracy (%) precision (%) (%) (%)
Proposed 98.99 99.05 98.86 99.03
GRU 96.05 96.12 97.98 96.08
LSTM 95.23 95.36 95.14 95.26
DNN 93.96 94.08 93.85 93.99
CNN 92.16 92.25 92.07 92.19
122

4.3.3 Ablation Study


Table 4.7 displays the ablation experiment of the proposed ROGRU by
evaluating different variants in terms of accuracy, precision, recall, and f1-score
metrics. Each component was trained from scratch using the same dataset split,
preprocessing pipeline, number of epochs, and hyperparameters as the full model.
In this case, our full pipeline achieves a better accuracy of 99.12%, precision of
98.74%, recall of 98.71%, and f1-score of 98.92%, illustrating the significance of
each component. Without KM-SMOTE, the performance of the model was
reduced, showing that the model struggled to handle the minority defect class.
Replacing SCDSNT121 with a standard CNN feature extractor also reduced the
performance, showing that its spatial and channel dual attention help capture both
discriminative defect patterns useful for PCB defect classification. Removing
SCRSO made the classifier less robust and increased complexity. Also, removing
CLAHE+AMF degrades the quality of the extracted patterns. Overall, the
outcomes show that each component contributes meaningfully to the final
performance of the model. Figure 4.11 and 4.12 shows the accuracy comparison
of ablation variants and impact of component removal on accuracy.

Table 4.7 Ablation experiment of proposed framework with other variants


Accuracy Precision Recall F1-score Accuracy
Variant
(%) (%) (%) (%) drop (%)
Full proposed model 99.12 98.74 98.71 98.92 0
Without SCRSO
97.84 97.91 97.75 96.87 1.28
(ROGRU only)
Without KM-SMOTE 96.52 96.63 96.41 96.55 2.60
SCDSNT121 + Standard
GRU 95.85 95.92 95.76 95.88 3.27

DenseNet121 + ROGRU 95.26 95.32 95.14 95.29 3.86


CNN features + ROGRU 93.54 93.61 93.67 93.57 5.58
Without Augmentation 94.52 94.63 94.46 94.55 4.60

Without CLAHE + AMF 94.42 94.53 94.35 94.45 4.70


123

Figure 4.11 Accuracy comparison of ablation variants

Figure 4.12 Impact of component removal on accuracy

4.3.4 Comparative Assessment of ROGRU with Existing Related Works

We evaluated the suggested model’s performance on the PCB defect


dataset against the current mainstream approaches documented in the literature
(Chapter 2) to confirm its benefits. Table 4.8 displays the outcomes of the
comparison experiments.
124

Table 4.8 Comparative assessment of ROGRU with existing related works


Author Name & Techniques
Outcomes
Year Used
Proposed ROGRU Accuracy= 99.12%
Ji et al. (2025) MS-DETR mAP = 96.90%
Accuracy = 95% and
Chen et al. (2024) Conv2D
recall = 94%
Average recall= 89.7% and
Xu et al. (2024) ConvNeXt
mAP = 95.4%
Accuracy = 95%, precision =
Huang & Tsai (2025) YOLOv3
95.6%, and recall = 98.2%
Improved Precision = 88.8%,
Yao et al. (2025)
YOLOv8 recall = 96.8%
Improved
Liu et al. (2024) mAP = 96.1% and mAP = 94.4%
YOLOv8
Improved mAP = 98.4%, precision = 98.66%,
Yuan et al. (2024)
YOLOv8 and recall = 95.18%
Improved
Yunpeng et al. (2025) Precision = 97.9%
YOLOv8

It has been demonstrated that our proposed solution outperforms other


methods in terms of classification accuracy, achieving 99.12% compared to
existing processes, primarily due to the inclusion of the proposed SCDSNT121
model, which enhances the contextual semantic information on the feature map
by assisting the model in capturing global spatial information. This enhances the
classifier's performance by facilitating the distinction between defect features and
the characteristics of similar backgrounds. In contrast, the existing MS-DETR,
ConvNeXt, and improved YOLOv8 models fail to capture those spatial
characteristics from the images, leading to poor classification results.
Additionally, the optimal tuning of hyperparameters with the help of the
125

SCRSO algorithm enables efficient exploration of the vast hyperparameter space


to find optimal or near-optimal configurations that enhance model accuracy and
generalization. In contrast, the existing MS-DETR, ConvNeXt, and improved
YOLOv8 models manually tune the hyperparameters, which may not effectively
explore the entire hyperparameter space, potentially missing out on better
combinations and reducing classification performance. In addition, the
KM-SMOTE balances the defects and non-defect samples, supporting the
enhancement of the model's generalization ability on unknown data, which leads
to more accurate predictions. Thus, this overall combinatorial strategy
demonstrates that while improving the model accuracy, computational and
memory resource control can be maintained in practical applications, making the
improved model more suitable for resource-constrained embedded devices.

4.4 SUMMARY

This chapter proposed a hyperparameter-tuned GRU model with an


enhanced feature learning framework. The effectiveness of the proposed ROGRU
model is investigated against the traditional GRU, LSTM, DNN, and CNN
models, and the performance of this chapter is evaluated based on accuracy,
precision, recall, F1-score, sensitivity, specificity, FPR, FNR, FRR, NPV, and
MCC metrics, respectively. Compared with existing mainstream detection
models, the proposed improved model, such as SCDSNT121-based effective
feature learning with KM-SMOTE-based data balancing, exhibits an excellent
performance of 99.12% accuracy in the classification and positioning of circuit
board defects. This improvement is mainly due to the model handles data
imbalance, feature extraction, and hyperparameter tuning. The KM-SMOTE
method helps to balance the class distribution, improving the model's ability to
generalize and predict minority classes accurately. The SCDSNT121 feature
extractor extracts deeper defect features than standard backbone models, giving
the model stronger feature representations. Furthermore, the SCRSO method
126

enhances robustness by selecting optimal hyperparameters. Together, these


components provide a cleaner, more accurate, and more dependable classification
framework, which is also validates through ablation experiments.

Although this work performs well, it is important to note that the


dataset used in this study is relatively small. In real PCB manufacturing, many
defects occur infrequently, which limits the availability of diverse training
samples. This limited data sample means the model may not fully capture all
variations of minority defects, even with KM-SMOTE-based dataset balancing.
Therefore, a larger sample would further enhance the generalization ability of the
proposed system.

You might also like