Page 47 - MSAM-4-3
P. 47
Materials Science in Additive Manufacturing AI-driven defect detection in metal AM
and EfficientNetV2-B0 models pre-trained on ImageNet 2.3. Object detection models
were imported from the TensorFlow/Keras library. Custom In the second phase of the task, manual annotation of the
fully connected layers were created for comparison, and dataset is required to achieve precise localization. In actual
after testing Flatten and GlobalAveragePooling2D, the powder bed images, 3 – 8 overlapping defects are commonly
former was selected. Two additional dense layers were added present, along with interference and noise, making it difficult
with 256 and 128 neurons, using Rectified Linear Unit to distinguish and label specific defect types accurately. Since,
(ReLU) as the activation function. Both models included in practical scenarios, the goal is only to detect the presence
a dropout layer, where ResNet-50 randomly dropped 20% and location of defects to stop printing in time and reduce
of the neurons to reduce reliance on specific neurons and losses, a simple and general bounding box annotation method
enhance generalization. Given that EfficientNetV2-B0 is sufficient to meet the requirements. For further research
converges quickly with a significant accuracy increase in into the causes of defects, pixel-level semantic segmentation
the early epochs, the dropout rate was increased to 0.3 to methods could be considered. In this study, LabelImg was
prevent overfitting. The last 5 – 10 convolutional layers were used to annotate the defect locations in all images as “defects,”
unfrozen, and the model was recompiled for further training, and the model learns from these annotations to predict
allowing it to learn the characteristics of the new dataset. potential defect locations in the test images, highlighting
To prevent training stagnation, a learning rate them with bounding boxes for inspection.
scheduling strategy was applied. The validation loss was Before training, approximately 10 – 20% of the
monitored, and if no decrease was observed over five images’ regions outside the build platform were cropped
epochs, the learning rate was reduced by 20% until 1e-6, to maintain a consistent image size, allowing for more
with an initial learning rate set to 1e-4. L2 regularization detailed information when inputting the images at 600 ×
was introduced to improve accuracy and was adjusted 600. The dataset was split using a commonly applied ratio,
from 0.02 to 0.001 to avoid excessive loss. During as displayed in Table 4. In addition to classification loss,
training, accuracy and loss steadily decreased, indicating Faster R-CNN also uses bounding box regression loss,
good convergence on the training set, but validation while the YOLOv5 model incorporates confidence loss.
loss remained constant, suggesting poor generalization.
To address this, the training-to-validation set ratio was In this experiment, the YOLOv5 model was selected
adjusted from 70:15:15 to 60:30:10, and the batch size was due to its availability in multiple sizes to meet different
set to 32. task requirements. It is based on PyTorch and features an
optimized architecture with reasonable model complexity,
In addition, an EarlyStopping callback was added to prevent
overfitting. EarlyStopping monitors the validation loss, and if it
fails to decrease over five epochs, training is stopped, and the Table 3. Parameter settings of ResNet‑50 and
model is reverted to the best-performing weights. Epochs were EfficientNetV2B0 models
increased to allow the accuracy to stabilize.
Parameters Specification
Given this study’s binary classification problem and ResNet‑50 EfficientNetV2B0
class imbalance, the loss function was modified from Batch size 32 32
binary cross-entropy loss to focal loss (γ = 2; α = 0.25) to Learning rate 1e-5 1e-4
optimize detection performance. Focal loss is an improved
version of cross-entropy loss that introduces a weighting Input image 224×224 224×224
size
factor α to give weights to the positive and negative classes,
focusing on harder-to-classify samples. This method is Loss function Focal loss (γ=2, α=0.25) Focal loss (γ=2, α=0.25)
more effective for handling class imbalance. In this dataset, Regularization L2 (0.001) L2 (0.001)
“good” was treated as the positive class (1) and “defects” Layer types Flatten, Dense (256), Flatten, Dense (256),
as the negative class (0). Although the classes were Dense (128), Dropout Dense (128), Dropout
relatively balanced, due to the nature of defect detection, Dropout rate 0.2 0.3
where missing a defect is undesirable, α was set to 0.25 to Epoch 50 50
encourage the model to focus more on the “defects” class. Data • Normalization: Rescale=1./255
augmentation • Rotation: Rotation range=40
These adaptations were designed specifically for the settings • Horizontal flip: Horizontal flip=True
characteristics of AM image data and helped improve • Width shift: Width shift range=0.2
model convergence and detection accuracy. The experiment • Height shift: Height shift range=0.2
involved training with various parameter combinations, • Shear: Shear range=0.2
and the final parameter settings are displayed in Table 3. • Zoom: Zoom range=0.2
Volume 4 Issue 3 (2025) 5 doi: 10.36922/MSAM025150022

