Crane hook identification method and system based on improved YOLOv8n and storage medium
By improving the YOLOv8n model, AKConv, ADown and CAFM Attention modules were introduced, the missed inspection problem in crane hook detection was solved, real-time and accurate hook identification was achieved, and industrial safety and efficiency were improved.
Patent Information
- Application Number
- CN202510529998.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
AI Technical Summary
The existing real-time detection methods of crane hooks are prone to missed inspections in complex industrial environments, resulting in loading and unloading incorrectness and safety accidents. The traditional methods are difficult to balance the detection speed and accuracy.
Using the improved YOLOv8n model, the dynamic adaptability of the convolution kernel is enhanced, feature loss is reduced, and global and local features are captured to build a crane hook recognition model.
Real-time detection of crane hooks is realized, the detection accuracy and speed is improved, collisions and accidents are avoided, and safety in industrial environments and the efficiency of loading and unloading goods is improved.
Smart Images

Figure CN120451085A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and more specifically, to a crane hook recognition method, system, and storage medium based on improved YOLOv8n. Background Art
[0002] With the rapid development of industry, cranes have become indispensable key equipment in many industrial fields, widely used in industries such as construction, ports, and steel. As a key component of cranes, real-time detection and identification of the hook's status is of great significance to industrial production and safety. With the development of industrial informatization and the popularization of computer vision technology, traditional industrial management methods have gradually shifted to intelligent management. However, in complex industrial scenarios, such as uneven lighting and noise interference, inaccuracies and misjudgments in detection and identification can easily occur, leading to loading and unloading errors and even safety accidents.
[0003] Currently, deep learning-based object detection methods are widely favored by scholars both domestically and internationally. They can be primarily categorized into two types: single-stage algorithms and two-stage algorithms. Two-stage algorithms first extract areas of the image that may contain objects, then perform feature extraction and classification. While these algorithms offer slightly higher recognition accuracy than single-stage algorithms, their recognition speed is significantly lower. Consequently, representative single-stage algorithms, such as the YOLO series, have experienced rapid development, with YOLO reaching 12 generations to date. Single-stage algorithms, characterized by their lightweight network architecture, offer detection speeds far exceeding those of two-stage algorithms. Therefore, given the real-time and accuracy requirements of detection, the YOLO algorithm has been widely used in various fields.
[0004] A series of studies have been conducted in China to address issues related to crane identification and detection in industrial scenarios. For example, the patent document with publication number "CN118982528A" discloses a YOLO-based method for detecting defects in key crane components. Although it uses an improved YOLO model for target detection, the missed detection rate in real-time detection is still high, and its performance still has much room for improvement. Summary of the Invention
[0005] In order to overcome the defect of the above-mentioned existing technology that there is still missed detection in the real-time detection of crane hooks, the present invention provides a crane hook recognition method, system and storage medium based on improved YOLOv8n. The present invention can detect the hook position in real time, help operators to make timely adjustments and judgments, avoid collisions or accidents, and improve safety in industrial environments; at the same time, the automatic recognition of the hook helps to help workers lock the hook position more quickly and perform precise loading and unloading operations, thereby improving work efficiency.
[0006] In order to solve the above technical problems, the technical solutions of the present invention are as follows:
[0007] A crane hook recognition method based on improved YOLOv8n includes the following steps:
[0008] S1: Obtain a crane hook dataset and preprocess it, then divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of crane hooks of different types;
[0009] S2: The YOLOv8n model is selected as the base model and improved. The AKConv module and ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFMAttention module is introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0010] S3: Iteratively train the crane hook recognition model using the training set to obtain a trained crane hook recognition model;
[0011] S4: Input the test set into the trained crane hook recognition model to perform target detection, and obtain the recognition result of each crane hook image in the test set.
[0012] Preferably, in step S1, the initially acquired crane hook dataset is first cleaned and screened, and then the crane type and hook position of each image are annotated using annotation software and converted into YOLO format, and then data enhancement processing is performed to complete the preprocessing.
[0013] Preferably, the crane types include at least: any one or more of gantry crane, bridge crane, tower crane, truck crane and flex-jib crane;
[0014] The data enhancement processing includes at least one or more of cropping, flipping, color conversion, noise injection and Gaussian transformation.
[0015] Preferably, in step S2, the crane hook recognition model includes a backbone network, a neck network, and a detection head network connected in sequence;
[0016] The backbone network includes: a first convolution module, a second convolution module, a first C2f module, a third convolution module, a second C2f module, an ADown module, a third C2f module, an AKConv module, a fourth C2f module, and an SPPF module connected in sequence;
[0017] The neck network includes the following sequentially connected layers: a first upsampling layer, a first splicing layer, a fifth C2f module, a second upsampling layer, a second splicing layer, a sixth C2f module, a fourth convolutional module, a third splicing layer, a seventh C2f module, a CAFM Attention module, a fifth convolutional module, a fourth splicing layer, and a sixth convolutional module; the output of the fifth C2f module is also connected to the input of the third splicing layer;
[0018] The output of the second C2f module is also connected to the input of the second splicing layer; the output of the third C2f module is also connected to the input of the first splicing layer; the output of the SPPF module is connected to the inputs of the first upsampling layer and the fourth splicing layer respectively;
[0019] The detection head network includes: a first detection head, a second detection head and a third detection head arranged in parallel;
[0020] The output of the sixth C2f module is connected to the input of the first detection head; the output of the seventh C2f module is connected to the input of the second detection head; the output of the sixth convolution module is connected to the input of the third detection head;
[0021] The outputs of the first detection head, the second detection head and the third detection head are collectively used as the output of the crane hook recognition model.
[0022] Preferably, in the ADown module, the input feature map is represented as X∈R C×H×W , where C represents the number of channels, H and W are the height and width respectively; perform an average pooling on the input feature map, which is expressed as:
[0023] X avg =AvgPool(X)
[0024] Among them, X avg Represents the feature map after average pooling; Avgpool represents the average pooling operation;
[0025] The feature map X after average pooling avg Split along the channel dimension into the first sub-feature map X avg1 and the second sub-feature map X avg2 , for X avg1 Perform convolution operation; avg2 Perform the convolution operation after the average pooling operation again; avg1 and X avg2 The merge is performed in the channel dimension as the final output of the ADown module.
[0026] Preferably, in the AKConv module, the convolution operation is first performed on the input feature map to obtain the offset of the convolution kernel, and then the offset is summed with the original coordinates of different positions of the input feature map to obtain the modified coordinates. After that, the modified feature map is obtained by interpolation and resampling, the modified feature map is reshaped, convolved and normalized again, and finally the final result is output through the activation function SiLU.
[0027] Preferably, the step S4 further includes: using a preset evaluation index to evaluate the performance of the trained crane hook recognition model.
[0028] Preferably, the evaluation indicators include at least: any one or more of precision P, recall R and mean average precision (mAP); the mean average precision (mAP) includes mAP50 and mAP50-95.
[0029] The present invention also provides a crane hook recognition system based on improved YOLOv8n, which applies the above-mentioned crane hook recognition method based on improved YOLOv8n, including:
[0030] Preprocessing unit: used to obtain and preprocess the crane hook dataset, and divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of hooks of different types of cranes;
[0031] Model building unit: This unit selects the YOLOv8n model as the base model and improves it. It introduces the AKConv and ADown modules into the YOLOv8n model's backbone network and the CAFM Attention module into the YOLOv8 model's neck network to build a crane hook recognition model.
[0032] Model training unit: used for iteratively training the crane hook recognition model using the training set to obtain a trained crane hook recognition model;
[0033] Recognition unit: used to input the test set into the trained crane hook recognition model to perform target detection and obtain the recognition result of each crane hook image in the test set.
[0034] The present invention also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps in the above method when executed by a processor.
[0035] Compared with the prior art, the beneficial effects of the technical solution of the present invention are:
[0036] The present invention provides a crane hook recognition method based on improved YOLOv8n. First, a crane hook dataset is obtained and preprocessed, and the preprocessed crane hook dataset is divided into a training set and a test set. Then, a YOLOv8n model is selected as a basic model and improved. The AKConv module and the ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFM Attention module is introduced into the neck network of the YOLOv8 model to construct a crane hook recognition model. Then, the crane hook recognition model is iteratively trained using the training set to obtain a trained crane hook recognition model. Finally, the test set is input into the trained crane hook recognition model for target detection, and a recognition result of each crane hook image in the test set is obtained.
[0037] This paper improves upon the YOLOv8n model by introducing the AKConv variable kernel convolution module to achieve variable convolution kernel parameters, effectively adapting to target changes. The paper supports linearly increasing or decreasing the number of convolution parameters, making it more adaptable to hardware environments. Furthermore, the paper embeds the ADown downsampling module into the backbone network, reducing the loss of feature details during the downsampling process. Furthermore, the paper introduces the CAFM Attention convolution fusion module, which can efficiently capture both global and local features of the crane hook.
[0038] The present invention can detect the hook position in real time, helping operators to make timely adjustments and judgments, avoiding collisions or accidents, and improving safety in industrial environments; at the same time, the automatic identification of the hook helps workers to lock the hook position more quickly and perform precise loading and unloading operations, thereby improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a flow chart of a crane hook recognition method based on improved YOLOv8n provided in Example 1.
[0040] Figure 2 This is a diagram of the YOLOv8n network structure provided in Example 2.
[0041] Figure 3 This is a diagram of the improved YOLOv8n network structure provided in Example 2.
[0042] Figure 4 This is a structural diagram of the AKConv module provided in Example 2.
[0043] Figure 5 This is a structural diagram of the ADown module provided in Example 2.
[0044] Figure 6This is a structural diagram of the CAFM Attention module provided in Example 2.
[0045] Figure 7 This is a diagram of the detection effect after adding noise interference provided in Example 2.
[0046] Figure 8 This is a structural diagram of a crane hook recognition system based on improved YOLOv8n provided in Example 3. DETAILED DESCRIPTION
[0047] The accompanying drawings are for illustrative purposes only and are not to be construed as limiting the present application;
[0048] In order to better illustrate this embodiment, some parts in the drawings may be omitted, enlarged, or reduced, and do not represent the actual product size;
[0049] It is understandable to those skilled in the art that some well-known structures and descriptions thereof may be omitted in the drawings.
[0050] The technical solution of the present invention is further described below with reference to the accompanying drawings and embodiments.
[0051] Example 1
[0052] like Figure 1 As shown, this embodiment provides a crane hook recognition method based on improved YOLOv8n, including the following steps:
[0053] S1: Obtain a crane hook dataset and preprocess it, then divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of crane hooks of different types;
[0054] S2: The YOLOv8n model is selected as the base model and improved. The AKConv module and ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFMAttention module is introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0055] S3: Iteratively train the crane hook recognition model using the training set to obtain a trained crane hook recognition model;
[0056] S4: Input the test set into the trained crane hook recognition model to perform target detection, and obtain the recognition result of each crane hook image in the test set.
[0057] In the specific implementation process, firstly, the crane hook dataset is obtained and preprocessed, and the preprocessed crane hook dataset is divided into a training set and a test set;
[0058] Then, the YOLOv8n model was selected as the base model and improved. The AKConv module and ADown module were introduced into the backbone network of the YOLOv8n model, and the CAFMAttention module was introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0059] Then, the crane hook recognition model is iteratively trained using the training set to obtain a trained crane hook recognition model;
[0060] Finally, the test set is input into the trained crane hook recognition model for target detection, and the recognition results of each crane hook image in the test set are obtained;
[0061] This method can detect the hook position in real time, helping operators to make timely adjustments and judgments, avoiding collisions or accidents, and improving safety in industrial environments. At the same time, the automatic identification of the hook helps workers to lock the hook position more quickly and perform precise loading and unloading operations, thereby improving work efficiency.
[0062] Example 2
[0063] This embodiment provides a crane hook recognition method based on improved YOLOv8n, including the following steps:
[0064] S1: Obtain a crane hook dataset and preprocess it, then divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of crane hooks of different types;
[0065] S2: The YOLOv8n model is selected as the base model and improved. The AKConv module and ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFMAttention module is introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0066] S3: Iteratively train the crane hook recognition model using the training set to obtain a trained crane hook recognition model;
[0067] S4: Inputting the test set into the trained crane hook recognition model to perform target detection, and obtaining a recognition result for each crane hook image in the test set;
[0068] In step S1, the initially acquired crane hook dataset is first cleaned and filtered, and then the crane type and hook position of each image are annotated using annotation software and converted into YOLO format, followed by data enhancement processing to complete the preprocessing;
[0069] The crane types include at least one or more of gantry cranes, bridge cranes, tower cranes, truck cranes and flex-jib cranes;
[0070] The data enhancement processing includes at least: any one or more of cropping, flipping, color conversion, noise injection and Gaussian transformation;
[0071] In step S2, the crane hook recognition model includes a backbone network, a neck network, and a detection head network connected in sequence;
[0072] The backbone network includes: a first convolution module, a second convolution module, a first C2f module, a third convolution module, a second C2f module, an ADown module, a third C2f module, an AKConv module, a fourth C2f module, and an SPPF module connected in sequence;
[0073] The neck network includes the following sequentially connected layers: a first upsampling layer, a first splicing layer, a fifth C2f module, a second upsampling layer, a second splicing layer, a sixth C2f module, a fourth convolutional module, a third splicing layer, a seventh C2f module, a CAFM Attention module, a fifth convolutional module, a fourth splicing layer, and a sixth convolutional module; the output of the fifth C2f module is also connected to the input of the third splicing layer;
[0074] The output of the second C2f module is also connected to the input of the second splicing layer; the output of the third C2f module is also connected to the input of the first splicing layer; the output of the SPPF module is connected to the inputs of the first upsampling layer and the fourth splicing layer respectively;
[0075] The detection head network includes: a first detection head, a second detection head and a third detection head arranged in parallel;
[0076] The output of the sixth C2f module is connected to the input of the first detection head; the output of the seventh C2f module is connected to the input of the second detection head; the output of the sixth convolution module is connected to the input of the third detection head;
[0077] The outputs of the first detection head, the second detection head and the third detection head are collectively used as the output of the crane hook recognition model;
[0078] In the ADown module, the input feature map is represented as X∈R C×H×W, where C represents the number of channels, H and W are the height and width respectively; perform an average pooling on the input feature map, which is expressed as:
[0079] X avg =AvgPool(X)
[0080] Among them, X avg Represents the feature map after average pooling; AvgPool represents the average pooling operation;
[0081] The feature map X after average pooling avg Split along the channel dimension into the first sub-feature map X avg1 and the second sub-feature map X avg2 , for X avg1 Perform convolution operation; avg2 Perform the convolution operation after the average pooling operation again; avg1 and X avg2 Merge in the channel dimension as the final output of the ADown module;
[0082] In the AKConv module, the convolution operation is first performed on the input feature map to obtain the offset of the convolution kernel, and then the offset is summed with the original coordinates of different positions of the input feature map to obtain the modified coordinates. Then, the modified feature map is obtained by interpolation and resampling. The modified feature map is reshaped, convolved again and normalized, and finally the final result is output through the activation function SiLU;
[0083] The step S4 further includes: using a preset evaluation index to evaluate the performance of the trained crane hook recognition model;
[0084] The evaluation indicators include at least: any one or more of precision P, recall R and mean average precision (mAP); the mean average precision (mAP) includes mAP50 and mAP50-95.
[0085] In the specific implementation process, firstly, the crane hook dataset is obtained and preprocessed, and the preprocessed crane hook dataset is divided into a training set and a test set;
[0086] In this example, crane hook samples were collected from multiple public websites. After screening and processing, the dataset was divided into five categories: gantry cranes, bridge cranes, tower cranes, truck cranes, and flex-jib cranes. The crane hooks were annotated using annotation software and converted into YOLO format.
[0087] Due to the limited data collected on the online platform, in order to enhance the robustness of the model, this embodiment also performed data augmentation processing (such as cropping, flipping, color conversion, noise injection, and Gaussian transformation). Ultimately, 1200 images were used for training. After preprocessing, the dataset was divided into a ratio of 8:1:1 for training, testing, and validation respectively. The details of the dataset are shown in Table 1:
[0088] Table 1 Number of hook images of different categories
[0089] category quantity Door hook 316 Bridge hook 231 Tower hook 206 Car-type hook 342 Flex-arm hook 105
[0090] Then, the YOLOv8n model was selected as the base model and improved. The AKConv module and ADown module were introduced into the backbone network of the YOLOv8n model, and the CAFMAttention module was introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0091] YOLOv8 is an important version of the YOLO target detection algorithm series. It has made many improvements and optimizations based on YOLOv5, significantly improving the detection accuracy and reasoning speed. In terms of network architecture, YOLOv8 adopts a more efficient CSP (Cross Stage Partial) structure, combined with depth-wise separable convolution, which reduces the amount of parameter calculation while improving the feature extraction capability. In terms of loss function optimization, BCE With Logits Loss is used instead of the traditional Softmax to improve the classification loss, and CIoU Loss is used to improve the regression loss. YOLOv8 achieves a better balance between reasoning speed and accuracy. In addition, YOLOv8 provides a variety of model sizes (such as YOLOv8n, YOLOv8s, YOLOv8m, YOLOv8l and YOLOv8x) to meet the needs of different scenarios. The network structure diagram of YOLOv8n used in this embodiment is shown in the figure below. Figure 2 As shown;
[0092] like Figure 3 The figure shows the structure of the improved YOLOv8n model. This embodiment uses YOLOv8n as the baseline model and makes the following improvements:
[0093] 1) To address the problems of traditional convolution with fixed receptive fields and lack of dynamic adaptability, we proposed replacing the Conv module in the backbone network with the AKConv module. This module dynamically adjusts the convolution kernel based on the content, improving the model's ability to extract different features and enhancing the model's dynamic adaptability.
[0094] Specifically, in order to solve the problems that traditional convolution operations are limited to local windows, the size of the convolution kernel is fixed, and the number of convolution operation parameters increases quadratically with the size, the Alternable Kernel Convolution (AKConv) module is introduced. Its structural diagram is shown in the figure below. Figure 4 As shown in the figure, this module gives the convolution kernel any number of parameters and any sampling shape, providing a rich choice between convolution kernels. It makes the number of convolution kernel parameters increase linearly, which is more adaptable to the hardware environment. In the AKConv module, first, let P represent the sampling network, then P can be expressed as:
[0095] P={(-1,-1),(-1,0),...(0,1),(1,1)}
[0096] Since the sampling network is regular, and the target of AKConv is irregular convolution kernel, in order to allow irregular convolution kernel to have a sampling network, an algorithm for convolution of any size is created, which generates the initial coordinates p of the convolution kernel. n , in the definition of irregular coordinates p n After that, the corresponding convolution operation formula at p0 is:
[0097] Conv(p0)=∑ω·(p0+p n )
[0098] In AKConv, the offset of the convolution kernel is first obtained by convolution operation, and the offset is compared with the original coordinate (p0+p n ) to obtain the modified coordinates, and finally obtain the features of the corresponding position through interpolation and resampling;
[0099] 2) To address the problem of severe data feature loss during the downsampling process, we propose to introduce an ADown module into the backbone network. This module dynamically adjusts the downsampling strategy based on the input features, retaining more information features and improving the flexibility of the model and the feature extraction capability.
[0100] Specifically, in the field of computer vision, downsampling is a key operation for efficient feature extraction and multi-scale feature fusion. It can effectively reduce the spatial dimension of feature maps. Traditional downsampling methods (such as strided convolution and pooling) are usually fixed and easily cause feature loss during the sampling process. ADown is an adaptive downsampling module that aims to dynamically adjust the downsampling method to reduce feature loss during the sampling process and better preserve the input feature information.
[0101] The structure of Adown is as follows Figure 5 As shown, first, the input feature map can be expressed as X∈R C×H×W, where C represents the number of channels, H and W are the height and width respectively; perform an average pooling on the input feature map, the process is expressed as:
[0102] X avg =AvgPool(X)
[0103] The feature map after average pooling is divided into two parts along the channel dimension X avg1 , X avg2 , Part I X avg1 Perform convolution operation, the process is expressed as:
[0104] X Conv1 =Conv(X avg1 )
[0105] For the second part X avg2 Perform the average pooling operation again and perform convolution to get X Conv2 , merge the feature maps generated by the two convolutions in the channel dimension as the final output;
[0106] 3) To address the difficulty of capturing global features during feature extraction, we introduced the CAFM Attention convolutional module. This module leverages the attention mechanism in the Transformer architecture to efficiently capture global features of the data.
[0107] Specifically, in YOLOv8n, due to the limited local receptive field in the convolution operation, it is difficult to effectively extract global features. The Transformer architecture, with the help of the attention mechanism, performs well in local and global feature extraction. Therefore, the convolution operation and the attention mechanism can complement each other; CAFM Attention is a convolution attention fusion module that effectively solves the loss of global features in the traditional convolution operation process, such as Figure 6 The figure shows the schematic diagram of the CAFM Attention module.
[0108] CAFM Attention consists of local branches and global branches. In the local branch, 1×1 convolution is first used to adjust the channel dimension. Then, the input tensor is divided into multiple groups along the channel dimension. Within each group, depthwise separable convolution is used to implement channel shuffling. Finally, each group of output tensors is concatenated along the channel number to generate a new tensor as the output. The formula of the local branch is:
[0109] F conv =W 3×3×3 (CS(W 1×1 (Y)))
[0110] Among them, F conv is the output of the local branch, W1×1 represents a 1×1 convolution, W 3×3×3 represents 3×3 convolution, CS represents shuffle operation, and Y is the input feature;
[0111] In the global branch, the self-attention Q (query), K (key), and V (value) are obtained through 1×1 and 3×3 convolution operations. Then, the attention map is obtained by the dot product of K and V and normalized using the SoftMax function. Then, V is multiplied by the attention map to obtain the weighted feature representation, and finally a 1×1 convolution is performed for feature integration. The output of the global branch is as follows:
[0112] F att =W 1×1 Attention(Q,K,V)+Y
[0113]
[0114]
[0115] Among them, SoftmMax() is the normalized activation function, so the total output of the CAFM Attention module is:
[0116] F out =F conv +F att
[0117] Then, the crane hook recognition model is iteratively trained using the training set to obtain a trained crane hook recognition model;
[0118] In this embodiment, the hardware configuration used for model training is as follows: the CPU is Xeon(R) platinum 8362@2.8GHz, 64GB memory, the GPU is NVIDIA GeForce RTX 3090, the operating system is Windows 10, the Pytorch deep learning framework is used, the CUDA version is 12.4, the number of training epochs is set to 300, the batch size is 32, and 640×640 pixels are selected as the pixels of the image input. The specific training environment is shown in Table 2;
[0119] Table 2 Experimental environment configuration
[0120] name Configuration operating system Windows 10 CPU Xeon(R)platinum 8362@2.8GHz GPU NVIDIA GeForce RTX 3090 epochs 300 batch 32 Deep Learning Framework Pytorch Image pixels 640×640
[0121] Finally, the test set is input into the trained crane hook recognition model for target detection, and the recognition results of each crane hook image in the test set are obtained;
[0122] To test the detection effect of the improved YOLOv8n model, this example also uses the following evaluation indicators: precision (P), recall (R), and mean average precision (mAP). mAP is composed of mAP50 and mAP50-95. The relevant calculation formula is as follows:
[0123]
[0124]
[0125] In order to prove the effectiveness of each module introduced in this method, this embodiment also designed an ablation experiment. The ablation experiment data is shown in Table 3.
[0126] Table 3 Ablation experiment results
[0127] YOLOv8n AKConv ADown CAFMAttention P R mAP50 mAP50-95 √ √ 91.6% 91.9% 95.7% 51.3% √ √ 92.6% 92.9% 95.7% 54.7% √ √ 92.2% 85.9% 91.7% 47.4% √ √ √ 94.7% 93.5% 96.2% 53.4% √ √ √ 95.1% 91.1% 95.1% 53% √ √ √ 94.1% 94.8% 96.3% 49.6% √ √ √ √ 95.9% 95.6% 96.3% 58.9% √ 91.3% 91.4% 92.8% 54.3%
[0128] As shown in Table 3, when the Conv module in the network is replaced by AKConv, the precision, recall and mAP50 are improved respectively. When the ADown module is introduced, not only the precision, recall and mAP50 increase by 1.3%, 1.5% and 2.9% respectively, but also the mAP50-95 index is improved by 0.3%. After the introduction of AKConv and ADown modules, the model steadily improves in precision, recall and mAP50, while mAP50-95 decreases slightly. By adding the CAFMAttention module, the mAP50-95 index reached 58.9%, an improvement of 4.5% compared to the baseline model YOLOv8n. Experimental results show that compared with the basic YOLOv8n model, the improved algorithm proposed in this method improves the precision, recall, mAP50 and mAP50-95 indicators by 4.6%, 4.2%, 3.3% and 4.6% respectively. While ensuring the precision and recall rates, the algorithm improves the average precision of detection.
[0129] Secondly, this embodiment also compares the improved YOLOv8n algorithm with other mainstream object detection algorithms (YOLOv5, YOLOv3-Tiny), and the results are shown in Table 4;
[0130] Table 4 Comparative experimental results
[0131] Model P R mAP50 mAP50-95 YOLOv8n 91.3% 91.4% 92.8% 54.3% Yolov8n-ODConv 88% 93.3% 93.5% 53.3% Yolov10n 89.2% 85.9% 88.9% 47.1% Improved YOLOv8n 95.9% 95.6% 96.3% 58.9% YOLOv5n 93.7% 87.4% 94.2% 51% YOLOv3-tiny 92.1% 93.3% 93% 53.3%
[0132] As shown in Table 4, the accuracy of the baseline model YOLOv8n is 91.3%, and the average accuracy reaches 92.8%. However, the YOLOv8n model with ODConv (plug-and-play dynamic convolution) has a poor accuracy value in the crane hook detection task, reaching only 88%. The average accuracy is 93.5%, slightly higher than the 92.8% of the baseline model. As an iterative version of YOLOv8, YOLOv10 lags behind the improved YOLOv8n model in all indicators in this detection task. The improved YOLOv8n model achieves 95.9%, 95.6% and 96.6% precision, recall and average accuracy in this detection task respectively.
[0133] In addition, this embodiment also uses the improved YOLOv8n model to perform instance detection on the validation set in the data set and other models in the comparative experiment. After detection, it is found that the use of the unimproved model has a small number of missed detections during the detection process, while the improved YOLOv8n model can accurately identify in different scenarios (such as open air and indoor workshops), and the missed detection rate is lower than that of the unimproved model.
[0134] When noise interference is added to the detection scene, such as uneven lighting, heavy objects hanging on the hook, etc., the detection effect is as follows Figure 7 As shown in the figure, the detection effect diagram shows that under the condition of adding some noise interference, the model in this method can still perform real-time detection of the crane hook under this condition;
[0135] In summary, this embodiment proposes an algorithm for crane hook recognition based on the YOLOv8n model. First, the deformable convolution AKConv is used to give the convolution kernel arbitrary parameters and shapes, providing more choices between convolution kernels. Second, the ADown module is introduced to reduce the loss of image features during the downsampling process. Finally, the CAFMAttention convolution fusion attention module is embedded to extract local features through local branches and global features through the self-attention mechanism in the global branch, effectively compensating for the difficulty in extracting global features due to the local receptive field in the convolution operation. The improved YOLOv8n algorithm achieves an average detection accuracy of 96.3% in the hook detection task, which is 4.6% and 4.2% higher than the baseline model. This shows that the improved YOLOv8n model has achieved good results and proves the effectiveness of the improvement. In actual industrial environments, it can help machines identify and locate crane hooks, to a certain extent ensure the safety of personnel in complex industrial environments, and improve the efficiency of crane loading and unloading.
[0136] Example 3
[0137] like Figure 8As shown, this embodiment provides a crane hook recognition system based on improved YOLOv8n, applying the crane hook recognition method based on improved YOLOv8n described in Example 1 or 2, including:
[0138] Preprocessing unit 301: used to obtain and preprocess a crane hook dataset, and divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes a plurality of hook images of different types of cranes;
[0139] Model construction unit 302: used to select the YOLOv8n model as the basic model and improve the YOLOv8n model by introducing the AKConv module and the ADown module into the backbone network of the YOLOv8n model and the CAFM Attention module into the neck network of the YOLOv8 model to build a crane hook recognition model;
[0140] Model training unit 303: configured to iteratively train the crane hook recognition model using the training set to obtain a trained crane hook recognition model;
[0141] The recognition unit 304 is configured to input the test set into the trained crane hook recognition model to perform target detection and obtain a recognition result for each crane hook image in the test set.
[0142] In a specific implementation process, first, the preprocessing unit 301 obtains and preprocesses the crane hook dataset, and divides the preprocessed crane hook dataset into a training set and a test set;
[0143] Next, in the model building unit 302, the YOLOv8n model is selected as the base model and improved. The AKConv module and the ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFM Attention module is introduced into the neck network of the YOLOv8 model to build a crane hook recognition model.
[0144] Then, the model training unit 303 uses the training set to iteratively train the crane hook recognition model to obtain a trained crane hook recognition model;
[0145] Finally, the recognition unit 304 inputs the test set into the trained crane hook recognition model to perform target detection and obtain the recognition results of each crane hook image in the test set;
[0146] This system can detect the hook position in real time, helping operators to make timely adjustments and judgments to avoid collisions or accidents, thereby improving safety in industrial environments. At the same time, automatic identification of the hook helps workers to lock the hook position more quickly and perform precise loading and unloading operations, thereby improving work efficiency.
[0147] The same or similar reference numerals correspond to the same or similar components;
[0148] The terms used in the drawings to describe positional relationships are for illustrative purposes only and are not to be construed as limiting the present application.
[0149] Obviously, the above embodiments of the present invention are merely examples for the purpose of clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all embodiments here. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the claims of the present invention.
Claims
1. A crane hook recognition method based on improved YOLOv8n, characterized in that: The following steps are involved: S1: Obtain a crane hook dataset and preprocess it, then divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of crane hooks of different types; S2: The YOLOv8n model is selected as the base model and improved. The AKConv module and ADown module are introduced into the backbone network of the YOLOv8n model, and the CAFM Attention module is introduced into the neck network of the YOLOv8 model to build a crane hook recognition model. S3: Iteratively train the crane hook recognition model using the training set to obtain a trained crane hook recognition model; S4: Input the test set into the trained crane hook recognition model to perform target detection, and obtain the recognition result of each crane hook image in the test set.
2. The crane hook recognition method based on improved YOLOv8n according to claim 1 is characterized in that: In step S1, the initially acquired crane hook dataset is first cleaned and filtered, and then the crane type and hook position of each image are annotated using annotation software and converted into YOLO format. After that, data enhancement processing is performed to complete the preprocessing.
3. The crane hook recognition method based on improved YOLOv8n according to claim 2 is characterized in that: The crane types include at least one or more of gantry cranes, bridge cranes, tower cranes, truck cranes and flex-jib cranes; The data enhancement processing includes at least one or more of cropping, flipping, color conversion, noise injection and Gaussian transformation.
4. The crane hook recognition method based on improved YOLOv8n according to claim 1 is characterized in that: In step S2, the crane hook recognition model includes a backbone network, a neck network, and a detection head network connected in sequence; The backbone network includes: a first convolution module, a second convolution module, a first C2f module, a third convolution module, a second C2f module, an ADown module, a third C2f module, an AKConv module, a fourth C2f module, and an SPPF module connected in sequence; The neck network includes the following sequentially connected layers: a first upsampling layer, a first splicing layer, a fifth C2f module, a second upsampling layer, a second splicing layer, a sixth C2f module, a fourth convolutional module, a third splicing layer, a seventh C2f module, a CAFM Attention module, a fifth convolutional module, a fourth splicing layer, and a sixth convolutional module; the output of the fifth C2f module is also connected to the input of the third splicing layer; The output of the second C2f module is also connected to the input of the second splicing layer; the output of the third C2f module is also connected to the input of the first splicing layer; the output of the SPPF module is connected to the inputs of the first upsampling layer and the fourth splicing layer respectively; The detection head network includes: a first detection head, a second detection head and a third detection head arranged in parallel; The output of the sixth C2f module is connected to the input of the first detection head; the output of the seventh C2f module is connected to the input of the second detection head; the output of the sixth convolution module is connected to the input of the third detection head; The outputs of the first detection head, the second detection head and the third detection head are collectively used as the output of the crane hook recognition model.
5. The crane hook recognition method based on improved YOLOv8n according to claim 1 is characterized in that: In the ADown module, the input feature map is represented as X∈R C×H×W , where C represents the number of channels, H and W are the height and width respectively; perform an average pooling on the input feature map, which is expressed as: X avg =AvgPool(X) Among them, X avg Represents the feature map after average pooling; AvgPool represents the average pooling operation; The feature map X after average pooling avg Split along the channel dimension into the first sub-feature map X avg1 and the second sub-feature map X avg2 , for X avg1 Perform convolution operation; aqvg2 Perform the convolution operation after the average pooling operation again; avg1 and X avg2 The merge is performed on the channel dimension as the final output of the ADown module.
6. The crane hook recognition method based on improved YOLOv8n according to claim 1 is characterized in that: In the AKConv module, the convolution operation is first performed on the input feature map to obtain the offset of the convolution kernel, and then the offset is summed with the original coordinates of different positions of the input feature map to obtain the modified coordinates. After that, the modified feature map is obtained by interpolation and resampling. The modified feature map is reshaped, convolved again and normalized, and finally the final result is output through the activation function SiLU.
7. A crane hook recognition method based on improved YOLOv8n according to any one of claims 1 to 6, characterized in that: The step S4 further includes: using a preset evaluation index to evaluate the performance of the trained crane hook recognition model.
8. The crane hook recognition method based on improved YOLOv8n according to claim 7 is characterized in that: The evaluation indicators include at least: any one or more of precision P, recall R and mean average precision (mAP); the mean average precision (mAP) includes mAP50 and mAP50-95.
9. A crane hook recognition system based on improved YOLOv8n, applying the crane hook recognition method based on improved YOLOv8n as claimed in any one of claims 1 to 8, characterized in that: include: Preprocessing unit: used to obtain and preprocess the crane hook dataset, and divide the preprocessed crane hook dataset into a training set and a test set; the crane hook dataset includes several images of hooks of different types of cranes; Model building unit: This unit selects the YOLOv8n model as the base model and improves it. It introduces the AKConv and ADown modules into the YOLOv8n model's backbone network and the CAFM Attention module into the YOLOv8 model's neck network to build a crane hook recognition model. Model training unit: used for iteratively training the crane hook recognition model using the training set to obtain a trained crane hook recognition model; Recognition unit: used to input the test set into the trained crane hook recognition model to perform target detection and obtain the recognition result of each crane hook image in the test set.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Visual analysis-based crane crane operation risk detection method and system
CN121121646A