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].
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:
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.