Next Article in Journal
Soil Erosion Risk Analysis in the Ría de Arosa (Pontevedra, Spain) Using the RUSLE and GIS Techniques
Previous Article in Journal
Accumulation of Glomalin-Related Soil Protein Regulated by Plantation Types and Vertical Distribution of Soil Characteristics in Southern China
Previous Article in Special Issue
Cut-to-Length Harvesting Prediction Tool: Machine Learning Model Based on Harvest and Weather Features
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

An Improved YOLOv5 Algorithm for Bamboo Strip Defect Detection Based on the Ghost Module

by
Ru-Xiao Yang
1,
Yan-Ru Lee
2,
Fu-Shin Lee
3,*,
Zhenying Liang
1 and
Yang Liu
4
1
College of Mechanical and Electrical Engineering, Wuyi University, Wuyishan 354300, China
2
Department of Computer Science & Information Engineering, National Taipei University of Technology, Taipei City 10608, Taiwan
3
Department of Technology for Smart Living, Huafan University, Shihtin, New Taipei City 223011, Taiwan
4
Yongan Institute of Bamboo Industry, Sanming 366000, China
*
Author to whom correspondence should be addressed.
Forests 2024, 15(9), 1480; https://doi.org/10.3390/f15091480
Submission received: 22 July 2024 / Revised: 10 August 2024 / Accepted: 21 August 2024 / Published: 23 August 2024
(This article belongs to the Special Issue New Development of Smart Forestry: Machine and Automation)

Abstract

:
Detecting surface defects in bamboo strips is essential for producing Asian bamboo products. Currently, the detection of surface defects in bamboo strips mainly relies on manual labor. The labor intensity is high, and the detection efficiency is low. Improving the speed and accuracy of identifying bamboo strip defects is crucial in enhancing enterprises’ production efficiency. Hence, this research designs a lightweight YOLOv5s neural network algorithm using the Ghost module to identify surface defects of bamboo strips. The research introduces an attention mechanism CA module to improve the recognition ability of the model target; the research also implements a C2f model to enhance the network performance and the surface quality of bamboo strips. The experimental results show that after training with the acquired image dataset, the YOLOv5s model can exert an intelligent detection effect on five common types of defects in bamboo strips, and the Ghost module makes YOLOv5s lightweight, which can effectively reduce model parameters and improve detection speed while maintaining recognition accuracy. Meanwhile, the C2f module and CA module can further leverage the model’s ability to identify specific defects in bamboo strips after lightweight improvement.

1. Introduction

The bamboo products industry is one of the essential industries in Asia [1]. Bamboo products have been widely used in China, Japan, South Korea, and Southeast Asia since ancient times [2,3], mainly including bamboo building materials, coffee table furniture, and bamboo chopsticks tableware [4]. It is well-known that strip ply bamboo is mainly the raw material used for building and furniture. It uses slender bamboo strips with a rectangular cross-section as the basic unit and consists of many slender bamboo strips with glue and pressure. The bamboo strips used to make bamboo boards are available in lengths of 1.2 m and 1.6 m, and the cross-section is a rectangular cross-section with a width of 15–18 mm and a thickness of 6–7 mm. Bamboo poles make these bamboo strips through cutting, planning, and chemical treatment. However, defects may exist on the bamboo surface during the growth and processing of bamboo strips. In order to ensure the quality and beauty of bamboo plywood, humans need to inspect each bamboo strip’s surface defects before splicing the laminated bamboo boards; therefore, bamboo strip inspection is one of the important processes. The surface inspection of bamboo strips is carried out simultaneously with the polishing process of bamboo strips or in the prescribed processes [5,6]. It mainly includes detecting whether there are five common defects on the surface of bamboo strips: flat yellow defects, concave yellow defects, green-black knot defects, yellow-black knot defects, and carbon defects, as shown in Figure 1. These defect features are essential indications of defects during the production process [7]. Bamboo strip inspection should not only distinguish existing defects but should accurately identify the types of defects. It is crucial because different defects correspond to different post-processing methods. Producers will use re-planning, polishing, or removal according to the type of defect. Since there are many types of surface defects on bamboo strips, the defects are irregularly distributed in various locations, easily making wrong or missed detections. Moreover, the production volume of bamboo strips is large, and the detection efficiency restricts the production efficiency of bamboo boards. Hence, reliable and efficient detection of bamboo strips is important in bamboo board production. Currently, surface defect detection of bamboo strips mainly relies on manual work. The level of operation automation is low, labor intensity is high, and labor costs are rising yearly, which restricts bamboo product companies’ production efficiency and profit margins. Due to the fact that environmental awareness has risen in recent years, the implementation of “replacing plastic with bamboo” has further increased the production demand for bamboo products enterprises in Asia area, and there is an urgent need to improve automated detection technology and equipment research to enhance development capabilities for the surface inspection of bamboo strips, as well as in promoting the intellectual and automation of agricultural machinery and equipment [8,9].
Therefore, there is an urgent need to enhance detection strategies for bamboo product surface defects and use new intelligent, automated equipment to develop a method for efficiently detecting bamboo strip surface defects [10,11,12]. Surface inspection of bamboo strips is done randomly and varies in shape and size. Traditional image recognition struggles with adapting to complex and variable recognition scenarios. Many Asian bamboo product companies are self-employed and lack funds for advanced intelligent equipment. Owners struggle to afford large-scale automated lines and lack scientific/technical personnel. Small intelligent testing equipment development has led to manual surface defect detection for bamboo strips, which is labor-intensive with low automation levels. Deep learning-based research has significantly advanced defect detection in products like steel strips, aluminum materials, and textiles in recent years [13,14,15]. Implementing deep learning’s ability to extract features and adapt to irregular shapes is crucial for studying detection strategies for bamboo strip surface quality, aiming to enhance bamboo equipment’s efficiency and intelligent development. Hence, this article suggests an efficient detection approach for bamboo strip surfaces using YOLOv5, focusing on the following two key aspects:
(1)
Suggest a novel image recognition method for bamboo strip surface defects by combining machine vision and convolutional neural networks to extract defect features automatically. The research aims to enhance the recognition of varied targets in shape and position while balancing speed and accuracy.
(2)
Suggest a lightweight YOLO network utilizing model structure enhancement, parameter reduction with a Ghost module, and optimization with a C2f module and a CA attention mechanism.

2. Prior Research Work

Nowadays, most surveyed studies on bamboo surface detection use machine vision and image processing technology. Zeng et al. collected bamboo strip images and matched them with bamboo strip defect characteristics in four aspects: color features, texture features, frequency domain amplitude spectral features, and mathematical morphology features [16]. Huang et al. employed morphological analysis, difference shadow method, adaptive Canny double threshold, edge extraction, and region growing approaches to detect defects like wormholes, cracks, green bamboo, and white on long bamboo strips [17]. Chen et al. created an algorithm for detecting bamboo chip shape defects by analyzing grayscale features. The study compared the segmentation effectiveness of the global threshold method and the Maximum Stable Extremal Region (MSER) method on bamboo slices [18].
Wang et al. proposed a method to construct multivariate images using multiscale representations and developed an efficient approach based on multiscale color texture eigenspace features to grade the surface of bamboo strips correctly [19]. Li et al. analyzed bamboo cane images through threshold segmentation, image filtering processing, and corresponding defect points through morphological and particle analysis [20]. Sun et al. detected the defects of the bamboo edge with the intensity of the light passing through the gap, using an optical fiber amplifier and an infrared photoelectric switch positioning the bamboo area [21]. Qin et al. improved a method for the “selection of bamboo strip” production process of bamboo flooring. The image inspection method can detect the major defects on the bamboo strip’s surface and distinguish the color of the main-used surface of the qualified bamboo strip [22]. Min et al. improved contour features by targeting the area, geometrical symmetry, and texture features, considering the average gradient to exercise defect detection of bamboo strips based on machine vision [23]. Kuang et al. proposed a method for defect detection of bamboo strips using a set of features based on LBP (Local Binary Pattern) and GLCM (Gray-level Co-occurrence Matrix), and the two algorithms are combined to detect the texture of the ROI region and finally applied the SVM classifier to classify the bamboo strips [9]. Traditional image processing methods for detecting bamboo surface defects rely on manually defined features, which struggle with defects’ random and varied nature. Since these methods use fixed feature templates, they face challenges adapting to diverse bamboo types, potentially resulting in missed or incorrect detections. Most image processing techniques rely on basic image features, which may not suffice to address the complex variations in bamboo strip defects. Methods based on Support Vector Machines (SVM) are typically designed for specific datasets and have limited generalization capabilities, making them less adaptable to other image data. Given the diverse varieties of bamboo strips and the significant differences in defect types and morphologies, although image processing techniques for bamboo strip defect detection have shown high accuracy and efficiency in specific experimental settings, there remain deficiencies in feature extraction and generalization capabilities.
Recently, researchers have combined target detection algorithms with deep learning algorithms [24,25,26]. Convolutional neural networks enable adaptive feature extraction and image classification, offering a new approach to target detection without the constraints of manually defined features. Researchers have utilized CNNs for automated detection in bamboo product analysis amidst agricultural informatization advancements [27,28]. Guo et al. incorporated asymmetric convolution and CBAM hybrid attention mechanism into YOLOv4-CSP, enhancing feature extraction horizontally on bamboo surfaces [8]. The approach involved utilizing asymmetric convolution for improved feature extraction and integrating key channels and region weights via the CBAM module to enhance the model’s capabilities. Liu et al. employed a radial basis function (RBF) neural network to spot surface defects on mahjong mat bamboo blocks, pinpointing key features and establishing an online detection system for workpiece defect characteristics [29]. Gao et al. analyzed bamboo stick surface defects using an enhanced CenterNet model, combining a pre-trained model core with an attention mechanism for superior results compared to YOLOv3 and the original CenterNet [30]. Jun-Song et al. developed a detection system for chopstick burr defects using a CNN method, optimizing the network structure for 94% accuracy and achieving 21 frames per second in transmission [31].
Researchers have not generally focused on bamboo product defect identification in AI studies. However, since wood and bamboo share natural origins, lessons could be drawn from identification methods for sawn wood surface features in this project category [32]. Sun et al. designed and developed an automatic detection method for wood surface defects using a deep learning algorithm and multi-criteria framework [33]. Based on the YOLOv3 network model, Yue H et al. reduced the multiscale detection network and improved the loss function to enhance the accuracy and speed of wood knot defect detection [34]. Li and Zhang applied YOLOv4 to identify knots, wormholes, and cracks in spruce-sawn timber, digitally assessing and analyzing the primary defects with successful recognition outcomes [35]. From above, we note that YOLOv5, a lightweight model in the YOLO algorithm series, efficiently balances model parameters and detection speed, reducing weight and calculations compared to YOLOv4, while maintaining solid prediction accuracy [36,37,38,39].
Note that CNN in deep learning excels at adapting to complex defects, but it is crucial to realize their heavy reliance on computer hardware due to numerous parameters and calculations, factors sometimes overlooked in previous studies. Direct integration into current production line control systems can cause slow detection and system jams. Small bamboo product businesses struggle to afford high-performance computer detection systems. Hence, researchers should devise a new method for identifying lightweight bamboo strip defects tailored to the needs of small enterprises.
On the other hand, lightweight neural networks offer scaled-down models, reduced parameter calculations, and lower hardware demands, ideal for industrial control computer deployment. Zhang et al. suggested adopting MobileNetv3 instead of Darknet53 in YOLOv3, simplifying the model, streamlining feature extraction, and introducing an IoU loss function for faster network convergence [40]. Mohsin et al. merged MobileNetV3 with Faster R-CNN to detect wood surface defects swiftly. MobileNetV3 was utilized for feature extraction, while Faster R-CNN efficiently classified features from input videos for prompt defect detection [41]. In 2021, Wang et al. substituted the original YOLOv3 backbone network with the lightweight MobileNetV3 model, altered the activation function, greatly diminished model parameters, and notably enhanced prediction speed [42].
Recently, researchers switched the backbone network’s residual block to a Ghost block structure for a lightweight model to address high network parameter calculations and real-time performance issues. In 2022, Hu et al. implemented the Ghost module to revamp YOLOv5’s backbone feature extraction network, cutting parameters and calculations with minimal accuracy loss [43]. Zhao et al. designed and used the Ghost module for convolution feature extraction in YOLOv4-tiny, enabling the algorithm to achieve good results in both speed and accuracy [44]. Zhang et al. used Ghost and CA to improve the YOLOv4 model, increasing precision and resolving the problem of accurate and rapid identification of apple objects [45]. Cheng et al. used Ghost and SE modules to improve the YOLOv5 model, enhancing the small target recognition ability based on lightweight neural networks [46]. Zhang et al. employed aerial images to identify pine blight, enhancing the YOLOv5 framework by integrating coordinated attention (CA), effective channel attention (ECA), convolutional block attention module (CBAM), and squeeze and excitation (SE). He discovered that the attention mechanism minimizes the influence of irrelevant features on model recognition, with the CA module proving the most effective without excessive parameter addition [47]. Xu et al. improved YOLOv5 to detect wood defects by incorporating the SimAM attention model into the network and using Ghost convolution to minimize model parameters [48]. The improved network balances recognition speed and accuracy for five categories of wood defects. Researchers enhanced feature fusion with the attention mechanism and BiFPN structure within a lightweight network model, enhancing multiscale feature fusion and small target feature detection without adding network parameters or computational complexity.
Regarding surface defect detection of bamboo strips, traditional machine vision, and image processing technology cannot adapt to the defect characteristics of bamboo strips of different sizes, shapes, and irregular distributions. Convolutional neural networks have apparent advantages but rely on the support of high-configuration computer hardware. Current lightweight algorithms can reduce calculation parameters and increase speed, but often at the expense of accuracy [49,50,51,52].
Nowadays, researchers have designed a lightweight neural network with a Ghost module for the surface defect detection of bamboo strips. By introducing the CA attention mechanism and C2f module based on the lightweight network model, the prior research also improved the performance of multiscale feature fusion and small target feature recognition, realizing the identification and classification of surface defects of bamboo strips, which has significant research significance for the detection technology of intelligent equipment for bamboo products.
Moreover, researchers have already incorporated the C2f module into the advanced YOLOv8 object detection network to enhance the network by running multiple gradient flow branches in parallel to gather more extensive gradient data, thereby optimizing performance [53]. For detecting the Forestry Pests, the C2f module is adopted to replace part of the C3 module of YOLOv5 to obtain richer gradient information [54]. Hence, it is important to consider applying the strategy to the basic architecture of the method, YOLOv5s, and adopting the C2f module to replace part of the C3 module to obtain richer gradient information [55,56].

3. Methods

3.1. Algorithm Improvement of YOLOv5s

The YOLOv5 model structure includes three parts: Backbone network, Neck network, and Head, as shown in Figure 2. The Backbone includes the CBS (Conv-BatchNorm-SiLU), C3, and SPPF modules. Researchers usually used the CBS for employed feature extraction, the C3 for enhanced feature extraction, and SPPF for multiscale feature fusion. The neck module adopts the PANet structure, which achieves goals through a feature pyramid structure that combines feature maps of varying resolutions, generating a new feature representation. The PANet structure effectively fuses feature maps from different levels to enhance detection performance. The head component predicts image features, constructs bounding boxes, and outputs feature maps for object detection. The YOLOv5 mainly offers four types: YOLOv5s, YOLOv5m, YOLOv5l, and YOLOv5x. Servers or workstations suit YOLOv5l and YOLOv5x, as these types contain many parameters. Personal computers can operate YOLOv5s and YOLOv5m as the models have fewer parameters than others. In particular, YOLOv5s runs the fastest and has the fewest parameters, considering that it can obtain excellent response and high accuracy among all the mentioned networks. The four versions of YOLOv5 share the same network architecture. Two parameters, depth factor (depth_multiple) and width factor (width_multiple), determine the size of the network structure. This article selects YOLOv5s_V6.1 as the baseline model for improving a lightweight design while ensuring detection accuracy.
For the lightweight YOLOv5s model, this article uses Ghost convolution modules to replace the original model’s CBS and C3 modules for the Backbone and Neck parts, as shown in Figure 3. Ghostconve combines BatchNorm (BN) with SiLU to become Ghostconve-BS to replace the original CBS. The Ghost convolution module combines standard convolution operations with linear operations. It performs a linear transformation on the generated convolution feature maps to obtain similar features and generates high-dimensional convolutions. At the same time, the C3Ghost module replaces the C3 module with the GhostBottleNeck. After making the model lightweight, this article adds the CA attention mechanism module to the Backbone of the original model to capture its area of interest faster. In the meantime, the C2f modules replace the original C3 modules in the Backbone part and update the Bottleneck times of C2f based on the original Bottleneck times in C3. The C2f modules improve the model’s robustness and enhance its detection ability for small targets for a lightweight model, which reduces the computational load.
The study lightens the original YOLOv5s model using Ghost convolution, further simplifying model parameters. Figure 4 illustrates the Ghost convolution module. While models like MobileNet and ShuffleNet reduce floating point calculations, they struggle to efficiently handle redundant feature maps from convolution. The Ghost convolution module first generates basic original feature maps through a 1 × 1 standard convolution and then performs φ1, φ2, …, and φk linear transformation on these original feature maps one by one. After obtaining another part of the redundant feature maps, the research combines this part of the feature maps with the original feature maps to increase the number of channels. This approach of obtaining redundant feature maps through linear operations can generate those redundant feature maps at less cost than ordinary convolution. Accordingly, the developed method simplifies the model by reducing total parameters.
Figure 5 illustrates the Ghost Bottleneck structure created by Ghost convolution. The approach divides the Ghost bottleneck module into two types according to the stride. When the convolution step size is Stride = 1, it comprises two stacked Ghost convolution modules. The first Ghost convolution module primarily expands the layer to increase the channels of the input feature map. The second Ghost convolution module reduces the number of feature map channels to match the shortcut path and then uses the shortcut to connect the inputs and outputs of these two Ghost modules. When the Stride = 2, the structure uses a depth-separable convolution and two Ghost convolution modules to reduce the number of parameters. In this step, the first Ghost convolution module acts as an expansion layer to increase the number of channels in the network, and the second Ghost convolution module reduces the number of network channels and matches the residual connection. When the approach does not use the ReLU activation function after the second Ghost module, the other layers use batch normalization (BN) and the ReLU nonactivation function after each layer. The essence of the Ghost bottleneck structure involves replacing standard convolution with Ghost convolution to reduce calculation parameters.

3.2. Replacement with C2F Module

The convolutional layer module used in YOLOv5s is the C3 module, and the C2f module is the convolutional layer module proposed in the latest target detection algorithm, as shown in Figure 6. The research improves part of the C2f module from the C3 module, which contains Conv and Bottleneck modules. These two modules are all consistent with the C3 module, and their composition structure generally refers to the composition of the ELAN (Efficient Long-range Attention Network) module. While ensuring it is lightweight, the model can obtain richer gradient information during training. In the target detection task, the feature extraction module’s performance significantly affects the model’s performance, so applying C2f to the Backbone network can improve YOLOv5s.

3.3. CA Attention Mechanism for Optimization

CA (Coordinate attention) improves the spatial understanding of deep learning models. By introducing coordinate information, the CA mechanism enhances the comprehension of the relationship between various locations in the data. The developed network enhances target identification and reduces computational expenses, as illustrated in Figure 7.
The developed strategy transforms any intermediate feature tensor X in the network and outputs feature tensor Y of the same size. H, W, and C present the input feature map’s height, width, and number of channels, respectively. The CA mechanism considers its positional relationship based on channel attention and combines it with spatial attention. This research divides the operational process into coordinated information embedding and attention generation. For input X, the pooling kernel (H,1) or (1,W) performs global average pooling for each channel along the height and width directions. Compared with global pooling, it helps the attention mechanism capture the long-distance relationship in one direction and retain the spatial location information in the other direction, making the object of network positioning more accurate than the original one.
The feature maps of the global receptive field’s width and height are spliced together and transmitted to the 1 × 1 convolution module, with the dimension decreased to the original C/r. After batch normalization, the characteristic figure is fed into the Sigmoid activation function, yielding the characteristic figure in the form of 1 × (W + H) × C/r.
The feature map is convolved by 1 × 1 according to the original height and width to obtain the feature maps with the same number of channels as the input X. Using the Sigmoid activation function, the attention weights in the height and width directions of the feature map is obtained. Lastly, the feature map integrates with the attention mechanism to maintain channel consistency.

4. Experiment Results and Discussion

In order to evaluate the algorithm’s impact, the study conducted experiments on a bamboo strip defect dataset, training, testing, and comparing it with other target detection algorithms.

4.1. Data Preparation and Experimental Conditions

Bamboo strip defect samples come from a Southern Asian bamboo strip processing enterprise, a typical bamboo strip production factory, including five common defects: flat yellow, concave yellow, green-black knot, yellow-black knot, and carbon defects, as Figure 1 shows.
The study sets up an experiment for bamboo strip inspection with linear light source illumination. Using an industrial camera, the team vertically scans the defects on the top of the bamboo strip, capturing images at 640 × 640 pixel resolution in jpg format. In the 640 × 640 photograph, the bamboo strip is narrow and elongated. The background, together with any of the bamboo defects in the image, was cropped in this paper to display the bamboo strip in a rectangular shape.
Researchers gathered around 10,000 defect images and annotated them in YOLO data format. Annotations include flat yellow and concave yellow defects, which have about 1200 labels each; green-black knot, yellow-black knot, and carbon defects, which have about 4000 labels each. The five types of defects total about 14,400 labels. Then, the data was split into training, validation, and test datasets in an 8:1:1 ratio.

4.2. Experimental Platform

In the experiment, the researchers used two E5-2682V4 @ 2.5GHz CPU as the workstation CPU models, 64 GB DDR4 memory, and two GeForce GTX 2080Ti GPU models with 12 GB video memory. The study used PyTorch to construct a deep learning framework on the 64-bit Windows 10 operating system and Python 3.8 to write programs, leveraging required libraries such as CUDA 11.8, Cudnn, and OpenCV to implement neural network model training.
For acceptable comparisons under the same conditions during the experiments, the researchers set the same initial training parameters for each group of experiments. This algorithm enhanced the YOLOv5-v6.1 version, training it with stochastic gradient descent (SGD) using 48 samples per batch. The researchers trained all models for 300 epochs. The study used Batch Normalization (BN) for regularization, with a momentum factor of 0.937, weight decay rate of 0.0005, and initial learning rate of 0.01.

4.3. Model Training Improvement and Ablation Experiment

The study evaluates performance using Average Precision (AP), Recall, Mean Average Precision (mAP), Weights, Giga Floating-point Operations Per Second (GFLOPs), and Frames Per Second (FPS). Average precision combines precision and recall, where precision signifies the correctly identified positives, and recall indicates ground-truth positive samples. Mean average precision averages the model’s performance across all categories. The explicit calculation formulas for the four indicators are delineated as follows:
Precision = T P T P + F P × 100 %
Recall = T P T P + F N × 100 %
Ap = 0 1 P r e c i s i o n d R e c a l l
mAP = i = 1 N A P i N × 100 %
Among them, TP (True Positive) is the number of samples where the target exists, FP (False Positive) is the number of samples where the target does not exist, FN (False Negative) is the number of samples where the target exists but is not recognized, and N is the number of categories. Hence, this research took the weight file with the highest mAP for each model as the final result.
After training and testing the mode, the mAP (Mean Average Precision), Train loss curves, and Validation loss curves were output, as shown in Figure 8a, Figure 8b and Figure 8c, respectively. From observing the mAP curve, which measures detection accuracy, the improved model stabilizes after the model is trained 250 times and reaches 97.6% after 300 training times. The mAP achieves 97.6%, indicating that the improved model accurately recognizes the five bamboo strip defects. As a comparative experiment, this study trained the YOLOv5s model, the YOLOv5_Ghost model, and the YOLOv5_Ghost_CA model after introducing the CA module and drew the curves in the same coordinate system. The final mAP value of our improved model is higher than YOLOv5_Ghost (95.8%) and YOLOv5_Ghost_CA (96.5%) and is the same as the mAP of YOLOv5s. Regarding training convergence speed, the improved model converges at the same speed as YOLOv5_Ghost and YOLOv5_Ghost_CA and tends to a stable value after about 250 times. The curve of YOLOv5s climbs faster and converges faster, and it tends to a stable value after about 200 training times.
The value for the train loss curve of the improved model is 0.658% when trained 300 times, which is slightly higher than the value of YOLOv5s of 0.62% and lower than YOLOv5_Ghost (0.712%) and YOLOv5_Ghost_CA (0.698%). The validation curve, which measures the model’s performance, indicates whether the model can correctly identify the target in the image with low validation obj_loss values. Note that from observing the validation loss curves, which start to stabilize after 250 times of training, the obj_loss drops to 0.217% after 300 times of training. The validation curve of YOLOv5s decreases quickly and stabilizes after 200 times, but the stability value of 0.225% is slightly higher than the improved model. The validation values for the other two models are 0.226% and 0.266%.
The ablation experiment aims to verify the optimization effect of each improved module. We first tested the effect of YOLOv5s on the bamboo surface dataset; then, we used the Ghost module to modify the YOLOv5 model for training and testing. Next, we introduced the CA attention mechanism and added the C2f module as our improved model. Table 1 demonstrates the experimental results.
After training the bamboo strip defect dataset 300 times, the training effect of the initial YOLOv5 network on the test set’s mAP was 97.6%, with a precision of 89.5%. On this basis, the Ghost module replaced the C3 and Conv of the Backbone and Neck, reducing the mAP and precision by 1.8% (to 95.8%) and 2.7% (to 86.8%). Although the accuracy decreased, the number of model parameters and calculations reduced significantly, and the model weights were reduced to 4.6M (by 47.2%), indicating that the Ghost module significantly affects model lightweight. On this basis, the research implemented the CA module to the Backbone, which improved the mAP to 96.5% (by 0.7%) and the precision to 90.0% (by 3.2%), with the Weights (the weight size) only adding 1.68 MB. The last column of Table 1 records the average time per epoch during training. A comparison reveals that the time required for each epoch has not increased significantly after model improvement. In other words, this study has enhanced the model’s performance with only a slight increase in time.
Based on the above YOLOv5-Ghost, the C2f module is improved on the Backbone and Neck, that is, using C2f to replace the C3Ghost in the Backbone of YOLOv5-Ghost; C2f to replace the C3Ghost in the Neck; and using C2f to replace all C3Ghost in the Backbone and Neck. Table 2 shows the obtained effects. The replaced model improved mAP compared to the YOLOv5-Ghost’s, which shows that C2f can optimize the model performance by appropriately increasing the model weights. At the same time, it is not true that replacing all the C3Ghost networks with the C2f networks achieves better results. C2f acts in different locations on the network and changes network performance differently. The comparison shows that after the C2f module improves on the Backbone, the precision reaches 89.9%, and the mAP reaches 97.1%. The detection speed of the model is 68.5 FPS. The precision exceeds other improvements of C2f and also exceeds the original YOLOv5s model. Although C2f completely replaces C3Ghost, the mAP reaches 97.3%, the weight reaches 15.7 MB, the speed decreases to 55.6 FPS, and the precision has no obvious advantage, making it challenging to effectively balance the calculation amount and accuracy.
Table 2 emphasizes that the addition improves network mAP to 97.6%, precision to 91.9%, and speed to 62.1 FPS, showing promising optimization. When replacing all instances of C2f to C3Ghost, precision rises to 92.7%, a 4.9% improvement post-CA inclusion. However, with increased Weights to 17.2 M and the FPS reduced to 54.1, it is better to implement this model for high-performance computers due to its resource-intensive nature. The last column of Table 2 allows for a comparison of the average time per epoch during training. The introduction of the CA attention mechanism increased the number of parameters, leading to an extended duration of each epoch. When incorporating the C2f enhancement into the network, the smaller computational load of C2f can reduce the time per epoch during training. When the study applies C2f to both the Backbone and Neck parts, the average time per epoch is shorter, but the model’s weight increases, which is not conducive to achieving a lightweight effect.
The study integrates the CA module into the C2f enhanced backbone network. Table 3 shows that implementing the Ghost module realizes the lightweight YOLOv5s network effectively, and combining the CA and C2f modules improves the mAP and precision of the network. However, the BiFPN structure enhances the YOLOv5 + Ghost + CA model’s neck section, decreasing precision by 1.2% and decreasing mAP by 1.8%; the average time of per-epoch increasing to 56 s. BiFPN falls short of the substantial impact seen with C2f and CA modules.
From above, this investigation asserts that YOLOv5 diminishes model weights while enhancing recognition performance via the enhancement framework integrating Ghost, CA, and C2f.
Table 4 compares precisions for the above networks’ executions in detecting various bamboo strip defects. As for detecting the flat yellow defect experiments, YOLOv5s achieved 80.2% precision. After incorporating the Ghost module for weight reduction, accuracy dipped slightly to 82.2%. The addition of the CA module improved accuracy to 87.9%. Integrating Ghost with C2f led to a slight accuracy reduction to 87.7%, later rising to 91.1% with the CA module. A lightweight CA module trims the computational load in YOLOv5s, reducing network size while improving target recognition slightly. The modified network, although different, performs comparably to YOLOv5s, boasting enhanced speed and fewer parameters.
However, the concave yellow defect, YOLOv5s, initially achieved 96% precision but was reduced to 85.3% when the Ghost module was implemented. Incorporating the CA module changed accuracy to 91.7%. The Ghost module added the C2f, and the recognition accuracy improved to 91% from 85.3%. Adding the CA module improved accuracy slightly to 94.1%, which is still less than the precision for YOLOv5s.
After employing BiFPN to modify the network, recognition accuracy decreased for bamboo strip defects, except carbon. BiFPN may be effective in other datasets but is unsuitable for flat_yellow, concave_yellow, green_black_knot, and yellow_black_knot defect detection in bamboo strips.

4.4. Comparative Experiment

Table 5 depicts the test results of the algorithm on the bamboo strip defects dataset, including YOLOv5s-Ghost, YOLOv5s, YOLOv7-tiny, YOLOv8n, and YOLOv9c, and the new algorithm in this study. YOLO networks show notable efficacy in identifying bamboo strip defects. Comparative analysis reveals that this article’s algorithm balances model size, accuracy, and speed when contrasted with YOLOv5s and YOLOv5s-Ghost models. The new YOLOv7, YOLOv8n, and YOLOv9c YOLO networks achieve a 2% precision and 0.3% mAP increase over the algorithm in this study with lower CPU detect speed performance.
The mAP serves as a critical metric for evaluating model performance. YOLOv7-tiny performs well, indicating good precision and recall, but lacks overall mAP value and CPU FPS. The YOLOv8n exhibits mAP results similar to this article, showing superior precision and recall with compact model weights. YOLOv8n replaces C3 with C2f and leverages anchor-free techniques for network optimization, resulting in a parameter-efficient model with enhanced performance. While YOLOv5 is ideal for CPU setups due to its equipment requirements, v8n excels with fewer parameters and better performance. Notably, YOLOv5 aligns well with CPU environments, offering stability and cost-effectiveness. Moreover, YOLOv9 outperforms the algorithm in defect identification, indicating enhanced performance. Regarding the Average Time per epoch, YOLOv7 and YOLOv9 could consume a significant amount of time.
The current YOLOv9 network has excessive memory requirements and high computational load, making it impractical for regular computers but suitable for network server clouds. As a result, YOLOv9 struggles to strike a balance between detection accuracy and speed for bamboo strip defect identification, rendering it unsuitable for standalone real-time detection. While YOLOv9 partially aims to slim down the YOLOv5s network, it falls short in developing a genuinely lightweight network design.
Figure 9 shows the detection results of the algorithm in this study. The network’s processing reveals the various recognized defects in the figures, and this research also shows the confidence values of the detection results from experiments. For example, in Figure 9, this research’s developed network can recognize the flat yellow defects with a confidence level of 0.93 (the maximum confidence value is 1), with a confidence level of 0.95 for the concave yellow defects, and with a confidence level of 0.95 for the carbon defects on the bamboo strip samples. The detection result diagram shows that the algorithm developed in this paper identified the five common bamboo strip defects well.
As shown in Figure 10, there are detection results of five types of bamboo strip defects, with six images for each. The areas framed in the images indicate the locations of the defects, and the names above the frames are the identified defect names, followed by the detection confidence level (maximum value of 1). The displayed bamboo strips exhibit significant color variations, and the defect shapes differ; some images even contain multiple defects. The research revealed that false detections of defects in bamboo strips were scarcely observed during the experimental process. Based on the confidence levels of the detected defects, the model can accurately determine the corresponding defect types. Meanwhile, the last image in the groups detecting flat yellow and concave yellow defects represents a model omission case. The defect colors are too close to the bamboo strip background, resulting in omissions. Overall, the model demonstrates good detection performance for the five bamboo strip defects mentioned in this research.

5. Conclusions

Surface defect detection of bamboo strips is an important process in producing bamboo plywood. The quality of bamboo strips directly affects the quality of subsequent products. Currently, bamboo strip manufacturing enterprises rely on manual visual identification, which has problems such as high labor costs, easy fatigue, and missed inspections. Many types of defects and irregular shapes and sizes characterize the surface defects of bamboo strips. Therefore, when research applies traditional image analysis technology to detect bamboo strip defects based on basic image features, it is difficult to meet the complex bamboo strip defect characteristics. Given the excellent performance of deep learning models in automatically extracting features, this article proposes a detection strategy for bamboo strip surface defects that improves the YOLOv5 model. This study trains the model to automatically extract defect features by constructing a dataset containing some bamboo strip defects. In order to weigh the amount of model calculation and recognition speed, this article uses the Ghost module to improve the convolution of the YOLOv5s model and the C3 convolution in Neck, reducing network parameters and calculation load and achieving lightweight improvements. In order to improve the feature recognition accuracy of the lightweight model, this study introduces the C2f module and CA attention mechanism. The improved model replaces the C3 convolution in Backbone with the C2f module to extract features at different scales, allowing the modified model to capture complex image features better. By implementing the CA attention mechanism and paying attention to image channel information and position information simultaneously, this research has effectively improved the object detection ability of the model for strip defects on bamboo surfaces without incurring too much computational overhead.
The researchers collected about 10,000 images to build a dataset based on five common bamboo defects contained. The dataset was trained by the improved YOLOv5 model. After training for 300 epochs, the improved model showed good performance and achieved fast and accurate defect detection effects of the lightweight model. The trained model’s [email protected] reached 97.6%, [email protected]:.95 was 92.6%, recall was 92.4%, precision reached 91.9%, and the model’s Weights was only 13M. Compared with the initial YOLOv5s, the improved model’s precision increased by 2.4%, [email protected]:.95 rose by 0.7%, and the model weights reduced by 1.4M, which is 10% lower than the weights of the original YOLOv5s, achieving lightweight improvements and recognition effects. Compared with the updated versions of YOLOv7, YOLOV8, and YOLOv9, the improved model in this article had mAP@5:0.95 at 92.6%, second only to YOLOv9, and its [email protected]%, and precision was lower than other high-version YOLO models. However, the FPS of the improved model on the CPU was 8.2, which was higher than other high-version YOLO models. It indicates that the improved model has low computer hardware requirements and can achieve better recognition speed by relying on CPU calculation and reasoning and balancing the hardware configuration and model. The performance is favorable to applications in industrial environments with low computer configurations. It is more suitable for bamboo processing companies to save computer hardware costs when applying YOLO detection technology. Although the current model has achieved good results in detecting defects on the surface of bamboo strips, detecting small object defects on bamboo strip surfaces is still challenging. Subsequently, this research will optimize the model to improve its detection capabilities for small object defects. Meanwhile, the number of samples for small object defects in bamboo strips is still small, and training the YOLO model on small sample datasets will be the next direction for this research. In summary, the experimental results of this study contribute a technical solution to a better detection approach for bamboo strip defects and promote the development of intelligent equipment design.

Author Contributions

Conceptualization, R.-X.Y. and Z.L.; Methodology, R.-X.Y.; Software, Y.-R.L.; Validation, R.-X.Y., Y.-R.L. and F.-S.L.; Formal Analysis, Z.L.; Data Curation, Y.L.; Writing—Original Draft Preparation, R.-X.Y.; Writing—Review & Editing, F.-S.L.; Project Administration, R.-X.Y.; Funding Acquisition, R.-X.Y. All authors have read and agreed to the published version of the manuscript.

Funding

The authors are grateful to the Chinese government for partial support under contract No. 2023J011043, as a Natural Science Foundation in the Fujian Province, China, for researching surface defect detection of bamboo strips and lighting weight of neural network. Furthermore, the authors are also grateful for the partial support under contract No. JAT210458, as a Scientific Foundation in the Fujian Province, China. The authors are also grateful to the Key Laboratory of Agriculture and Machinery Intelligent Control and Manufacturing Technology in the Wuyi University of the Fujian Province, China, and the support from the Yongan Institute of Bamboo Industry at the Yongan City, Fujian Province, China.

Data Availability Statement

Data are contained within the article.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Buziquia, S.T.; Lopes, P.V.F.; Almeida, A.K.; de Almeida, I.K. Impacts of bamboo spreading: A review. Biodivers. Conserv. 2019, 28, 3695–3711. [Google Scholar] [CrossRef]
  2. Ayer, S.; Timilsina, S.; Aryal, A.; Acharya, A.K.; Neupane, A.; Bhatta, K.P. Bamboo forests in Nepal: Status, distribution, research trends and contribution to local livelihoods. Adv. Bamboo Sci. 2023, 4, 100027–100038. [Google Scholar] [CrossRef]
  3. Agrawal, H.; Das, A.A. Study bamboo as a structural element for efficiency and sensitivity in building and interior elements. Int. J. Multidiscip. Res. 2023, 5. E-ISSN: 2582-2160. [Google Scholar]
  4. Liu, W.; Hui, C.; Wang, F.; Wang, M.; Liu, G. Review of the resources and utilization of bamboo China. In Bamboo—Current and Future Prospects; InTech: London, UK, 2018; pp. 133–142. [Google Scholar]
  5. Xiansheng, Q.; Feng, H.; Qiong, L.; Xin, S. Online defect inspection algorithm of bamboo strip based on computer vision. In Proceedings of the 2009 IEEE International Conference on Industrial Technology, Churchill, VIC, Australia, 10–13 February 2009; pp. 1–5. [Google Scholar]
  6. Peng, X.Q. Study on development strategy analysis of new bamboo-slices products in Wanbei area. J. Phys. Conf. Ser. 2018, 1087, 42–49. [Google Scholar] [CrossRef]
  7. Huang, Y.; Yi, M.; Yang, W.; Yang, M. Research on detection method of sheet surface defects based on machine vision. Conf. Ser. Earth Environ. Sci. 2021, 632, 52–85. [Google Scholar] [CrossRef]
  8. Guo, Y.; Zeng, Y.; Gao, F.; Qiu, Y.; Zhou, X.; Zhong, L.; Zhan, C. Improved YOLOv4-CSP algorithm for detection of bamboo surface sliver defects with extreme aspect ratio. IEEE Access 2022, 10, 29810–29820. [Google Scholar] [CrossRef]
  9. Kuang, H.; Ding, Y.; Li, R.; Liu, X. Defect detection of bamboo strips based on LBP and GLCM features by using SVM classifier. In Proceedings of the 2018 Chinese Control and Decision Conference (CCDC), Shenyang, China, 9–11 June 2018; pp. 3341–3345. [Google Scholar]
  10. Ding, F.; Zhuang, Z.; Liu, Y.; Jiang, D.; Yan, X.; Wang, Z. Detecting defects on solid wood panels based on an improved SSD algorithm. Sensors 2020, 20, 5315. [Google Scholar] [CrossRef] [PubMed]
  11. Zhao, Z.; Yang, X.; Zhou, Y.; Sun, Q.; Ge, Z.; Liu, D. Real-time detection of particleboard surface defects based on improved YOLOV5 target detection. Sci. Rep. 2021, 11, 21777–21792. [Google Scholar] [CrossRef]
  12. Zhao, H.; Wan, F.; Lei, G.; Xiong, Y.; Xu, L.; Xu, C.; Zhou, W. LSD-YOLOv5: A steel strip surface defect detection algorithm based on lightweight network and enhanced feature fusion mode. Sensors 2023, 23, 6558. [Google Scholar] [CrossRef]
  13. Tu, Y.; Ling, Z.; Guo, S.; Wen, H. An accurate and real-time surface defects detection method for sawn lumber. IEEE Trans. Instrum. Meas. 2020, 70, 1–11. [Google Scholar] [CrossRef]
  14. Liu, Y.; Hou, M.; Li, A.; Dong, Y.; Xie, L.; Ji, Y. Automatic detection of timber-cracks in wooden architectural heritage using YOLOv3 algorithm. Remote Sens. Spat. Inf. Sci. 2020, 43, 1471–1476. [Google Scholar] [CrossRef]
  15. Samek, W.; Montavon, G.; Lapuschkin, S.; Anders, C.J.; Müller, K.R. Explaining deep neural networks and beyond: A review of methods and applications. Proc. IEEE 2021, 109, 247–278. [Google Scholar] [CrossRef]
  16. Zeng, Q.; Lu, Q.; Yu, X.; Li, S.; Chen, N.; Li, W.; Zhao, W. Identification of defects on bamboo strip surfaces based on comprehensive features. Eur. J. Wood Wood Prod. 2023, 81, 315–328. [Google Scholar] [CrossRef]
  17. Huang, B. Research on Long Bamboo Batten Surface Defect Detection and Color Classification Based on Machine Vision. Master’s Thesis, Guangxi Normal University, Guilin, China, 2018. [Google Scholar]
  18. Chen, Z. Research and Application of a Detection System for Bamboo Chip Defects Based on Machine Vision. Master’s Thesis, Hubei University of Technology, Wuhan, China, 2018. [Google Scholar]
  19. Wang, X.Y.; Liang, D.T.; Deng, W.Y. Surface grading of bamboo strips using multiscale color texture features in eigenspace. Comput. Electron. Agric. 2010, 73, 91–98. [Google Scholar] [CrossRef]
  20. Li, Y.; Ye, S. Defect Inspection System of Carbonized Bamboo Cane Based on LabVIEW and Machine Vision. In Proceedings of the 2017 IEEE International Conference on Information, Communication, and Engineering, Xiamen, China, 17–20 November 2017; Lam, A.D.K.-T., Meen, T.-H., Prior, S.D., Eds.; IEEE: Piscataway, NJ, USA, 2017; pp. 314–317. [Google Scholar]
  21. Sun, T.; Mou, X.; Song, S.; Li, J. Defective edge detection system design for long bamboo batten. In Proceedings of the 2017 International Conference on Electronic Industry and Automation, Suzhou, China, 23–25 June 2017; Volume 145, pp. 246–250. [Google Scholar]
  22. Qin, X.; Song, X.; Liu, Q.; He, F. Online Detection and Sorting System of Bamboo Strip Based on Visual Servo. In Proceedings of the 30th Chinese Control and Decision Conference, Shenyang, China, 9–11 June 2018; pp. 3345–3353. [Google Scholar]
  23. Min, C.; Yu, S.; Jia, G.; Liu, D.; Wan, K. Comprehensive defect detection of bamboo strips with new feature extraction machine vision methods. J. Adv. Manuf. Sci. Technol. 2023, 4, 2023018. [Google Scholar] [CrossRef]
  24. Hu, J.F.; Yu, X.; Zhao, Y.F. Bamboo defect classification based on improved transformer network. Wood Res. 2022, 67, 501–510. [Google Scholar] [CrossRef]
  25. Hu, J.; Yu, X.; Zhao, Y.; Wang, K.; Lu, W. Research on bamboo defect segmentation and classification based on improved u-net network. Wood Res. 2022, 67, 109–122. [Google Scholar] [CrossRef]
  26. Kim, S.Y.; Lee, J.; Mok, C.; Kim, S.; Moon, S.; Kyeong, Y.; Jin, Y.S.; Lee, W.; Choi, J.M.; Kim, S.B. Defect detection and cause analysis on display electrostatic chuck fab process using deep learning algorithms. Daehan San’eob Gonghag Hoeji 2022, 48, 151–162. [Google Scholar]
  27. Zhou, H.; Liu, Y.; Liu, Z.; Zhuang, Z.; Wang, X.; Gou, B. Crack detection method for engineered bamboo based on super-resolution reconstruction and generative adversarial network. Forests 2022, 13, 1896. [Google Scholar] [CrossRef]
  28. Kang, X.; Nagasawa, S.; Wu, Y.; Xiong, X. Emotional design of bamboo chair based on deep convolution neural network and deep convolution generative adversarial network. J. Intell. Fuzzy Syst. 2022, 44, 1977–1989. [Google Scholar] [CrossRef]
  29. Liu, T.H.; Wu, Z.D.; Chen, Q.L.; Nie, X.N.; Li, G.Q.; Wang, H.J.; Wu, J.M. Intelligent bamboo part sorting system design via machine vision. For. Prod. J. 2021, 71, 27–38. [Google Scholar] [CrossRef]
  30. Gao, Q.; Huang, B.; Liu, W.; Tong, T. Bamboo strip surface defect detection method based on improved CenterNet. J. Comput. Appl. 2021, 41, 1933–1938. [Google Scholar]
  31. Chen, J.S.; He, Z.F.; Zhang, Y.H. Defect detection method of chopsticks based on improved YOLOv3 algorithm. Food Mach. 2020, 36, 133–138. [Google Scholar]
  32. Han, S.; Jiang, X.; Wu, Z. An improved YOLOv5 algorithm for wood defect detection based on attention. IEEE Access 2023, 11, 71800–71810. [Google Scholar] [CrossRef]
  33. Sun, P. Wood quality defect detection based on deep learning and multi-criteria framework. Math. Probl. Eng. 2022, 2022, 26–29. [Google Scholar]
  34. Yue, H.; Bai, R. Research on a detection method for wood knot defect based on improved YOLOv3. Autom. Instrum. 2020, 41, 29–35. [Google Scholar]
  35. Li, D.; Zhang, Z.; Wang, B.; Yang, C.; Deng, L. Detection method of timber defects based on target detection algorithm. Measurement 2022, 203, 111937–111938. [Google Scholar] [CrossRef]
  36. Sun, S.; Yang, X.; Peng, J. Yolo-based lightweight object detection with structure simplification and attention enhancement. In Proceedings of the 2023 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), Rhodes Island, Greece, 4–10 June 2023; pp. 1–5. [Google Scholar] [CrossRef]
  37. Yang, R.; Zhang, J.; Shang, X.; Li, W. Lightweight small target detection algorithm with multi-feature fusion. Electronics 2023, 12, 2739. [Google Scholar] [CrossRef]
  38. Feng, J.; Zhou, M.; Hao, E.; Pan, C. Lightweight target detection method based on improved YOLOv5. In Proceedings of the International Conference on Image, Signal Processing, and Pattern Recognition 2023 (ISPP), Changsha, China, 24–26 February 2023; Volume 12707, pp. 734–739. [Google Scholar]
  39. Deng, L.; Bi, L.; Li, H.; Chen, H.; Duan, X.; Lou, H.; Zhang, H.; Bi, J.; Liu, H. Lightweight aerial image object detection algorithm based on improved YOLOv5s. Dent. Sci. Rep. 2023, 13, 7817–7827. [Google Scholar] [CrossRef]
  40. Zhang, X.; Li, N.; Zhang, R. An improved lightweight network MobileNetv3 Based YOLOv3 for pedestrian detection. In Proceedings of the 2021 IEEE International Conference on Consumer Electronics and Computer Engineering (ICCECE), Guangzhou, China, 15–17 January 2021; pp. 114–118. [Google Scholar]
  41. Mohsin, M.; Balogun, O.S.; Haataja, K.; Toivanen, P. Real-time defect detection and classification on wood surfaces using deep learning. Electron. Imaging 2022, 34, IPAS-382. [Google Scholar] [CrossRef]
  42. Wang, B.; Yang, C.; Ding, Y.; Qin, G. Detection of wood surface defects based on improved YOLOv3 algorithm. BioResources 2021, 16, 6766–6776. [Google Scholar] [CrossRef]
  43. Hu, W.; Yang, L.; Xiao, Y. A lightweight network model for identifying helmet wearing. Comput. Eng. Appl. 2023, 59, 149–155. [Google Scholar]
  44. Zhao, F.; Li, Y. Lightweight indoor human target detection algorithm based on improved YOLOv4-tiny. J. Electron. Inf. 2022, 44, 3815–3824. [Google Scholar]
  45. Zhang, C.; Kang, F.; Wang, Y. An improved apple object detection method based on lightweight YOLOv4 in complex backgrounds. Remote Sens. 2022, 14, 4150. [Google Scholar] [CrossRef]
  46. Cheng, S.; Yang, H.; Xu, X. An improved lightweight detection algorithm for X-ray aluminum alloy weld defects based on YOLOv5. China Laser 2022, 49, 136–144. [Google Scholar]
  47. Zhang, P.; Wang, Z.; Rao, Y.; Zheng, J.; Zhang, N.; Wang, D.; Gao, X. Identification of pine wilt disease infected wood using UAV RGB imagery and improved YOLOv5 models integrated with attention mechanisms. Forests 2023, 14, 588. [Google Scholar] [CrossRef]
  48. Xu, J.; Yang, H.; Wan, Z.; Mu, H.; Qi, D.; Han, S. Wood surface defects detection based on the improved YOLOv5-C3Ghost with SimAm module. IEEE Access 2023, 11, 105281–105287. [Google Scholar] [CrossRef]
  49. Cao, Y.; Liu, F.; Jiang, L.; Bao, C.; Miao, Y.; Chen, Y. Lightweight wood panel defect detection method incorporating attention mechanism and feature fusion network. arXiv 2023, arXiv:2306.12113. [Google Scholar] [CrossRef]
  50. Yue, X.; Zhong, G.; Chu, B. A multi-attention fusion mechanism for collaborative industrial surface defect detection. In Proceedings of the Fourteenth International Conference on Graphics and Image Processing (ICGIP 2022), Nanjing, China, 21–23 October 2023; Volume 12705, pp. 209–218. [Google Scholar]
  51. Zou, C.; Ye, L. Image super-resolution network based on feature fusion attention. J. Sens. 2022, 1, 5864752. [Google Scholar] [CrossRef]
  52. Lin, M.; Wang, Z.W.; Huang, L. Analysis and research on YOLOv5s vehicle detection with CA and BiFPN fusion. In Proceedings of the 2022 Eurasia Conference on IOT, Communication and Engineering (ECICE), Yunlin, Taiwan, 28–30 October 2022; pp. 201–205. [Google Scholar]
  53. Yu, G.; Zhou, X. An improved YOLOv5 Crack detection method combined with a bottleneck transformer. Mathematics 2023, 11, 2477. [Google Scholar] [CrossRef]
  54. Liu, D.; Lv, F.; Guo, J.; Zhang, H.; Zhu, L. Detection of forestry pests based on improved YOLOv5 and transfer learning. Forests 2023, 14, 1484. [Google Scholar] [CrossRef]
  55. Wang, T.; Zhai, Y.; Li, Y.; Wang, W.; Ye, G.; Jin, S. Insulator defect detection based on ML-YOLOv5 algorithm. Sensors 2024, 24, 204. [Google Scholar] [CrossRef] [PubMed]
  56. Xu, H.; Pan, H.; Li, J. Surface defect detection of bearing rings based on an improved YOLOv5 Network. Sensors 2023, 23, 7443. [Google Scholar] [CrossRef] [PubMed]
Figure 1. Five different defect marks show respective distribution position, shape, and area size in bamboo strips.
Figure 1. Five different defect marks show respective distribution position, shape, and area size in bamboo strips.
Forests 15 01480 g001
Figure 2. The Original structure of YOLOv5s.
Figure 2. The Original structure of YOLOv5s.
Forests 15 01480 g002
Figure 3. The Improved structure of YOLOv5s.
Figure 3. The Improved structure of YOLOv5s.
Forests 15 01480 g003
Figure 4. Schematic diagram of the Ghost convolution module.
Figure 4. Schematic diagram of the Ghost convolution module.
Forests 15 01480 g004
Figure 5. The Ghost bottleneck structure.
Figure 5. The Ghost bottleneck structure.
Forests 15 01480 g005
Figure 6. The structure of the C2f module.
Figure 6. The structure of the C2f module.
Forests 15 01480 g006
Figure 7. CA attention mechanism module.
Figure 7. CA attention mechanism module.
Forests 15 01480 g007
Figure 8. Network training results for bamboo strip defect detection.
Figure 8. Network training results for bamboo strip defect detection.
Forests 15 01480 g008
Figure 9. Confidence levels from experiments for bamboo strips with various types of defects.
Figure 9. Confidence levels from experiments for bamboo strips with various types of defects.
Forests 15 01480 g009
Figure 10. The detection results for bamboo strips with various types of defects.
Figure 10. The detection results for bamboo strips with various types of defects.
Forests 15 01480 g010aForests 15 01480 g010b
Table 1. Summary of Ghost-CA ablation experiments.
Table 1. Summary of Ghost-CA ablation experiments.
ModelWeights
MB
Precision
%
Recall
%
[email protected]%[email protected]:0.95%GFLOPsAverage Time per Epoch/s
YOLOv5s14.489.595.997.691.916.547
YOLOv5 + Ghost7.686.893.095.889.08.147
YOLOv5 + Ghost + CA9.2890.091.796.590.78.954
Our improved model13.091.992.497.692.61652
Table 2. Summary of C2f ablation experiments.
Table 2. Summary of C2f ablation experiments.
ModelBackboneNeckCAWeights
MB
Precision
%
Recall
%
[email protected]%[email protected]:0.95%GFLOPsFPSAverage Time per Epoch/s
YOLOv5s + Ghost 7.686.893.095.889.08.164.547
11.589.992.897.192.015.168.550
11.586.496.696.390.812.166.248
15.787.896.397.392.217.155.648
13.091.992.497.692.61662.156
13.091.192.1979112.959.658
17.292.790.997.091.920.054.153
Table 3. Summary of all ablation experiments.
Table 3. Summary of all ablation experiments.
ModelWeights
MB
Precision
%
Recall
%
[email protected]%[email protected]:0.95%GFLOPsAverage Time per Epoch (s)
YOLOv5s14.489.595.997.691.916.547
+ Ghost + CA9.2890.091.796.590.78.954
+ Ghost + CA + backC2f (ours)13.091.992.497.692.61652
+ Ghost + CA + BiFPN10.688.890.995.788.99.856
Table 4. Comparison of precisions for five categories of bamboo strip defects.
Table 4. Comparison of precisions for five categories of bamboo strip defects.
ClassYOLOv5sYOLOv5s-GhostYOLOv5s-Ghost-CAYOLOv5s-Ghost-backC2fYOLOv5s-Ghost-
backC2f-CA
YOLOv5s-Ghost-CA-BIFPN
All89.586.890.089.991.988.8
Yellow-black knot96.294.895.395.596.293.7
Green-black knot96.595.496.596.597.694.6
Flat yellow80.282.287.987.791.182.1
Concave yellow9685.391.79194.189.3
Carbon78.676.378.778.880.684.3
Table 5. Comparisons of various YOLO experimental results for bamboo strip defect detection.
Table 5. Comparisons of various YOLO experimental results for bamboo strip defect detection.
NetworksWeights MBPrecision
%
Recall
%
[email protected]%mAP@5:0.95%GFLOPsFPS
(GPU)
FPS
(CPU)
Average Time per Epoch (s)
YOLOv5n6.788.994.895.687.74.249.310.044
YOLOv5s-Ghost7.686.893.095.889.08.164.510.447
YOLOv5s14.489.595.997.691.916.576.911.647
YOLOv712.39492.797.991.2106.577.55.8299
YOLOv8n7.295.395.39879.328.4822.958
YOLOv9c5094.396.59893.9266.218.56415
Developed
algorithm
13.091.992.497.692.61662.18.252
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Yang, R.-X.; Lee, Y.-R.; Lee, F.-S.; Liang, Z.; Liu, Y. An Improved YOLOv5 Algorithm for Bamboo Strip Defect Detection Based on the Ghost Module. Forests 2024, 15, 1480. https://doi.org/10.3390/f15091480

AMA Style

Yang R-X, Lee Y-R, Lee F-S, Liang Z, Liu Y. An Improved YOLOv5 Algorithm for Bamboo Strip Defect Detection Based on the Ghost Module. Forests. 2024; 15(9):1480. https://doi.org/10.3390/f15091480

Chicago/Turabian Style

Yang, Ru-Xiao, Yan-Ru Lee, Fu-Shin Lee, Zhenying Liang, and Yang Liu. 2024. "An Improved YOLOv5 Algorithm for Bamboo Strip Defect Detection Based on the Ghost Module" Forests 15, no. 9: 1480. https://doi.org/10.3390/f15091480

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop