Light-weight optical fiber adapter rotating target detection method based on improved YOLOv8n
By improving the YOLOv8n model, combined with modules such as MobileViTv3, Ghost Bottleneck v2 and Dynamic Head, the loss function and label allocation strategy are optimized, and the problem that traditional object detection methods are difficult to achieve high precision and real-time in complex fiber patch panel scenarios is solved, and efficient rotation frame object detection and lightweight deployment are achieved.
Patent Information
- Application Number
- CN202510046212.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional object detection methods are difficult to achieve the dual requirements of high accuracy and real-time in complex scenarios such as fiber patch panels, especially when dealing with fiber adapters in arbitrarily oriented.
Based on the improved YOLOv8n's lightweight fiber adapter rotation object detection method, the Ghost Bottleneck v2 module is introduced to the neck network by integrating the MobileViTv3 module into the C2f module of the backbone network, the Ghost Bottleneck v2 module is introduced to the neck network, the Dynamic Head is used to improve the detection head structure, and the Angle DFL Loss and Dynamic ATSS is introduced to optimize the loss function and label allocation strategy.
The requirement for high-precision detection and lightweight deployment in fiber adapter detection tasks is realized, significantly reducing computing overhead and improving feature extraction and fusion efficiency, suitable for deployment on embedded devices.
Smart Images

Figure CN119810425A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer vision and target detection, and in particular to a lightweight optical fiber adapter rotating target detection method based on improved YOLOv8n. Background Art
[0002] Optical fiber distribution frames (ODFs) are key equipment in modern communication networks and are widely used in fiber-optic communication interactive systems to interconnect cables inside optical fiber distribution frames. However, optical fiber distribution frames need to be manually calibrated before leaving the factory. The encoder value corresponding to each optical fiber adapter port is manually determined, which is inefficient and easy to introduce errors. It not only increases production costs, but also limits the productization and large-scale production of optical fiber distribution frames. In order to solve these problems, automated and intelligent optical fiber encoder detection algorithms are particularly important. By introducing deep learning target detection algorithms, accurate positioning of optical fiber encoders can be achieved. The optical fiber adapter ports are rectangular in shape and arranged in a circular ring in the optical fiber distribution frame. Their position and direction are crucial to the correct connection of optical fiber jumpers. Traditional target detection methods perform well when processing regular oriented targets, but in complex scenarios such as optical fiber distribution frames where the ports are oriented arbitrarily, it is difficult to meet the dual requirements of accuracy and practicality. To this end, it is necessary to transform the detection task of optical fiber adapters from traditional target detection to rotating frame target detection to adapt to their unique geometric features.
[0003] At present, the detection methods of rotating frame objects are mainly divided into two categories: Anchor-based detection algorithms and Anchor-Free detection algorithms. Anchor-Based algorithms are represented by Rotated Faster R-CNN, Rotated RetinaNet and GlidingVertex, which realize accurate detection of rotating objects by designing rotating frame Anchor templates. This type of algorithm can effectively capture the rotation characteristics of the object and is suitable for scenes with diverse object shapes. However, the complexity of Anchor settings leads to high computational overhead, which limits the real-time and lightweight nature of the algorithm.
[0004] In response to the above problems, scholars have designed lightweight models. For example, Li et al. proposed R-YOLOv5, which introduced the Transformer module, which reduced the computational complexity while enhancing the semantic information and global perception of small targets; Huang et al. proposed the lightweight network SP-YOLO-Lite, which introduced lightweight convolutional modules and attention mechanisms, optimized the detection backbone network and neck structure, significantly reduced the computational and parameter overhead, and achieved efficient deployment on embedded devices.
[0005] In summary, research on model lightweighting mainly focuses on replacing lightweight modules and model compression, but it is usually accompanied by a decrease in accuracy, making it difficult to achieve high-precision detection of the fiber optic adapter base. Summary of the invention
[0006] Purpose of the invention: In order to overcome the shortcomings of the prior art, the present invention focuses on the high-precision and lightweight requirements for fiber optic adapter detection in fiber optic distribution frames, and proposes an improved rotating frame target detection method based on YOLOv8n, which solves the problems that traditional target detection algorithms are difficult to adapt to targets with arbitrary orientations, and complex models are difficult to deploy in embedded devices. To achieve the above purpose, the present invention provides the following solutions:
[0007] Technical solution: The present invention provides a lightweight optical fiber adapter rotating target detection method based on improved YOLOv8n, comprising the following steps:
[0008] S1: Collect images of fiber optic adapters in real scenes, annotate the data and perform data augmentation to expand the dataset;
[0009] S2: Improved on the basis of YOLOv8n-OBB model, MobileViTv3 was integrated into the C2f module of the backbone network; Ghost Bottleneck v2 was integrated into the C2f module of the neck network; Dynamic Head was used to improve the detection head structure.
[0010] S3: Use the improved YOLOv8n-OBB lightweight model for training evaluation, introduce Angle DFL Loss as the loss function during training; integrate the label assignment strategy Dynamic ATSS module.
[0011] S4: After completing the training, retain the optimal weight model after training; and conduct experimental tests on the trained model.
[0012] Furthermore, the step one is specifically as follows: labeling data refers to using the Roboflow tool to manually and accurately label the collected images according to the fiber optic adapter, the execution claw and 10 types of digital characters with a rotated rectangular box; the preprocessing refers to expanding the data set by using random rotation, random translation, random flipping, random cropping, random erasing, Gaussian noise, changing brightness and other data enhancement methods, and randomly dividing the data set into a training set, a validation set, and a test set in a ratio of 8:1:1.
[0013] Furthermore, the step 2 is specifically as follows: integrating MobileViTv3 into the C2f module of the backbone network; integrating Ghost Bottleneck v2 into the C2f module of the neck network; and using Dynamic Head to improve the detection head structure.
[0014] The C2f module of the MobileViTv3 integrated into the backbone network is specifically: the introduction of the MobileViTv3 module can better achieve a balance between efficient calculation and feature expression. The improved module is called C2f_MViTBv3. Taking into account the relationship between the efficiency and performance of the model, the present invention only replaces the C2f modules of the 5th and 7th layers in the backbone network with C2f_MViTBv3, so that the performance of the model is greatly improved without significantly increasing the model parameters.
[0015] The C2f module of the Ghost Bottleneck v2 integrated into the neck network is specifically as follows: In Neck, the standard bottleneck structure in all C2f modules is replaced with Ghost Bottleneck v2, and the improved module is called C2f_GhostBlockv2 module. After the replacement, the low computational cost and efficient feature expression capability of the Ghost module can be effectively utilized, while significantly reducing the model parameters.
[0016] The lightweight fiber optic adapter rotating target detection method based on improved YOLOv8n is characterized in that the Dynamic Head improved detection head structure is specifically: an attention mechanism is introduced into the detection head, and the original detection head is replaced with a dynamic detection head Dynamic Head. This modular design of stacking step by step significantly reduces the computational complexity while maintaining flexibility and expressiveness. The input of the Dynamic Head is a feature tensor of uniform scale, and the output is suitable for a variety of target detection tasks, such as classification and regression, which can effectively improve the target detection performance.
[0017] Furthermore, the Angle DFL Loss loss function is as follows: Angle distribution focus loss (AngleDFL) is introduced to transform the angle prediction task from regression to distribution modeling. By discretizing the angle, Angle DFLLoss can improve the stability and accuracy of the prediction. Angle DFL Loss discretizes the target angle into distribution points within a fixed range, and each angle value is mapped to a set of probability distributions. The distribution loss is obtained by calculating the difference between the predicted distribution and the target distribution, and the final angle loss is normalized by the sum of the target scores as shown in formula (1):
[0018]
[0019] Furthermore, the dynamic label assignment strategy Dynamic ATSS is specifically as follows: incorporating the prediction information into the definition of positive and negative samples, calculating the combined IoU by combining the IoU of the predicted bounding box and the IoU of the anchor box, and dynamically adjusting the label assignment strategy based on this.
[0020] The combined IoU of the two is defined as formula (2):
[0021] CIoU=IoU pred +IoU anchor (2)
[0022] The dynamic threshold is calculated using the mean and standard deviation of the combined IoU as shown in formula (3):
[0023] T=μ CIoU +σ CIoU (3)
[0024] By introducing prediction information, Dynamic ATSS can significantly improve the accuracy of positive and negative sample allocation. The prediction box is closer to reality than the predefined anchor box because the final detection result and NMS algorithm are based on the prediction box rather than the anchor box. Dynamic ATSS can flexibly adjust the positive sample allocation rules and focus on samples with increasing prediction quality, thereby improving the overall performance of the network and detection accuracy.
[0025] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects:
[0026] This paper proposes a lightweight fiber adapter rotation target detection method based on improved YOLOv8n to meet the needs of high-precision detection and lightweight deployment. By integrating the MobileViTv3 module into the C2f module of the backbone network, the optimization of local and global feature separation is realized, the feature expression ability is improved, and the computational cost is significantly reduced; the Ghost Bottleneck v2 module is introduced in the neck network, combined with the Ghost module and the decoupled fully connected attention mechanism, which greatly reduces the computational overhead and enhances the feature fusion efficiency; the dynamic detection head is adopted to achieve efficient feature allocation through the attention mechanism of scale, space and task dimensions, and improve the adaptability of the model to complex scenes; the loss function is optimized, and the angle distribution focus loss (Angle DFL Loss) is introduced to improve the stability and accuracy of rotating box target detection; through the dynamic label allocation strategy (Dynamic ATSS), the positive and negative sample allocation rules are adaptively adjusted to further improve the detection performance. The experimental results show that the lightweight fiber adapter rotation target detection method based on improved YOLOv8n achieves excellent accuracy and performance in the fiber adapter detection task, and has good lightweight characteristics, which is suitable for deployment on embedded devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0028] Figure 1 A flow chart of a method provided by an embodiment of the present invention;
[0029] Figure 2 A schematic diagram of a technical route provided by an embodiment of the present invention;
[0030] Figure 3 Provide an improved YOLOv8n network model structure diagram for an embodiment of the present invention;
[0031] Figure 4 Provide a C2f_MViTBv3 network structure diagram for an embodiment of the present invention;
[0032] Figure 5 Provide a C2f_GhostBlockv2 network structure diagram for an embodiment of the present invention;
[0033] Figure 6 Provide a Dynamic Head network structure diagram for an embodiment of the present invention;
[0034] Figure 7 This is the detection effect diagram of the original YOLOv8n-OBB model;
[0035] Figure 8 This is a detection effect diagram of the improved YOLOv8n-OBB model used in the present invention; DETAILED DESCRIPTION
[0036] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0038] The purpose of the present invention is to provide a lightweight fiber optic adapter rotating target detection method based on improved YOLOv8n, which is suitable for embedded devices and effectively improves detection efficiency and accuracy.
[0039] Figure 1 A flow chart of a method provided by an embodiment of the present invention, such as Figure 1 As shown, the present invention provides a lightweight optical fiber adapter rotating target detection method based on improved YOLOv8n, comprising:
[0040] Step 100: Collecting images of optical fiber adapters in real scenes and annotating data, and preprocessing the data set;
[0041] Step 200: Improve the YOLOv8n OBB model by introducing the MobileViTv3 module to optimize the backbone network; introduce the Ghost Block module to optimize the neck network; use Dynamic Head to improve the detection head structure;
[0042] Step 300: Optimize the improved YOLOv8n OBB lightweight model, introduce Angle DFL Loss as the loss function, and introduce the dynamic label allocation strategy Dynamic ATSS;
[0043] Step 400: After the training is completed, the optimal weight model after training is retained; the trained model is subjected to experimental testing;
[0044] like Figure 2 As shown, the specific technical route of this embodiment includes steps 1 to 4 in total, which are as follows:
[0045] Step 1: Collect images of optical fiber adapters in real scenes and annotate the data, and preprocess the data set.
[0046] Specifically, the dataset is named FA dataset, which is a self-built fiber optic adapter image dataset. The dataset includes different fiber optic patch panel scenes, such as fiber optic adapter ports, actuators, digital logos and other elements, aiming to increase the diversity of the dataset, improve the performance of the model in practical applications, and improve the robustness and generalization ability of the model.
[0047] The Roboflow tool was used to manually and accurately annotate the collected images with rotated rectangular boxes according to fiber optic adapters, execution claws and 10 types of digital characters; preprocessing refers to expanding the dataset by using data enhancement methods such as random rotation, random translation, random flipping, random cropping, random erasing, Gaussian noise, and changing brightness, and randomly dividing the dataset into training set, validation set, and test set in a ratio of 8:1:1.
[0048] Step 2: Based on the YOLOv8n-OBB model, the following optimizations are performed: the MobileViTv3 module is used to improve the performance of the backbone network; the Ghost Block module is used to enhance the efficiency of the neck network; and the Dynamic Head is used to optimize the detection head architecture. The improved YOLOv8n network model structure is shown in the figure below: Figure 3 shown.
[0049] Specifically, the introduction of the MobileViTv3 module can better achieve a balance between efficient computing and feature expression. The improved module is called C2f_MViTBv3 (e.g. Figure 4 ). Taking into account the relationship between model efficiency and performance, the present invention only replaces the C2f modules of the 5th and 7th layers in the backbone network with C2f_MViTBv3, which greatly improves the performance of the model without significantly increasing the model parameters. This improvement not only improves the efficiency of feature extraction, but also significantly reduces the computational cost, making it possible to deploy the model on resource-constrained embedded devices.
[0050] Specifically, in Neck, the standard bottleneck structure in all C2f modules is replaced by Ghost Bottleneckv2, and the improved module is called C2f_GhostBlockv2 module (such as Figure 5 ). After the replacement, the low computational cost and efficient feature expression capability of the Ghost module can be effectively utilized, while significantly reducing model parameters. This improvement significantly improves the efficiency of feature fusion, reduces computational overhead, and further optimizes the lightweight degree of the model, making it more suitable for efficient operation on embedded devices.
[0051] Specifically, the attention mechanism is introduced into the detection head, and the original detection head is replaced by the dynamic detection head DynamicHead (such as Figure 6 ). This modular design of stacking layers significantly reduces computational complexity while maintaining flexibility and expressiveness. The input of Dynamic Head is a feature tensor of uniform scale, and the output is suitable for a variety of target detection tasks, such as classification and regression, which can effectively improve target detection performance. This improvement improves the adaptability of the model to complex scenes, and significantly improves its detection accuracy and robustness in different environments.
[0052] Step 3: Further optimization measures are implemented for the above-mentioned lightweight YOLOv8n-OBB model, including using AngleDFL Loss to optimize the loss function calculation and introducing Dynamic ATSS to achieve dynamic label allocation, so as to improve the model training effect and detection accuracy;
[0053] Specifically, the Angle DFL Loss is introduced to transform the angle prediction task from regression to distribution modeling. By discretizing the angle, Angle DFL Loss can improve the stability and accuracy of the prediction. This improvement effectively solves the periodicity problem of the rotation box angle prediction and significantly enhances the model's sensitivity to small changes in angle, thereby improving the model's performance in the rotation object detection task.
[0054] Specifically, a dynamic label assignment strategy (Dynamic ATSS) is adopted to incorporate prediction information into the definition of positive and negative samples. In the early training stage, due to the poor prediction quality caused by the random initialization of the network, Dynamic ATSS is still dominated by the traditional Anchor IoU. As the training progresses, the quality of the predicted box gradually improves, and the predicted IoU begins to dominate the allocation process of positive samples. This dynamic adjustment enables the label assignment strategy to be continuously optimized as the training state of the network, thereby selecting more samples with high-quality predictions as positive samples. This improvement significantly improves the accuracy of the allocation of positive and negative samples. The predicted box is closer to reality than the predefined Anchor box, which ultimately improves the overall performance and detection accuracy of the network.
[0055] Step 4: After the training is completed, the optimal weight model after training is retained; the trained model is subjected to experimental testing;
[0056] Specifically, after training is completed, the weight model with the best performance during the training process is retained. This model is the model version with the best performance selected through the validation set evaluation in multiple training cycles. Subsequently, the optimal model is applied to the experimental test phase to evaluate its detection effect and performance in actual scenarios. Figure 7 (Detection effect diagram of the original YOLOv8n-OBB model) and Figure 8 (Detection effect diagram of the improved YOLOv8n-OBB model used in the present invention) It can be intuitively seen that the improved model has significantly improved detection accuracy and detail recognition. Figure 8 It shows that the angle of the rotated rectangle generated by the improved model is closer to the actual angle of the object. Figure 7 The original model in the figure has deviations in angle alignment, which shows that the improved model has higher accuracy when dealing with rotated targets. This step is crucial to verify the effectiveness and reliability of the model and provides a scientific basis for the final deployment and practical application of the model.
[0057] In summary, the present invention solves the problem that traditional target detection methods cannot adapt to targets of arbitrary orientations in fiber optic communication scenarios when detecting fiber optic adapters, and that it is difficult for embedded devices to directly deploy complex detection models. The present invention uses high-precision detection and lightweight deployment as dual-objective optimization to achieve the best detection strategy. Based on the improved YOLOv8 model, the present invention introduces a directional bounding box to accurately locate the position and orientation of the fiber optic adapter. At the same time, considering the lightweight requirements of the model, the feature extraction and fusion efficiency are optimized through modules such as MobileViTv3, Ghost Bottleneck v2 and Dynamic Head, which greatly reduces the model calculation overhead. In addition, the Angle DFL Loss and Dynamic ATSS are introduced to optimize the loss function and label allocation strategy, improve the stability and accuracy of rotating frame target detection, and effectively improve the detection level of fiber optic adapters.
[0058] The beneficial effects of the present invention are as follows:
[0059] (1) The present invention can accurately locate the position and orientation of the optical fiber adapter by introducing a rotating frame target detection.
[0060] (2) The present invention adopts a lightweight design, which reduces the computational cost and improves the feature extraction capability. Through lightweight feature expression and efficient attention mechanism, the feature fusion efficiency is further optimized, which is suitable for efficient operation in embedded devices.
[0061] (3) The present invention optimizes the loss function and label allocation strategy, improves the stability and accuracy of rotating frame object detection, and adaptively adjusts the positive and negative sample allocation rules to further improve the stability of the training process and detection accuracy.
[0062] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0063] The principles and implementation methods of the present invention are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and core idea of the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A lightweight fiber optic adapter rotating target detection method based on improved YOLOv8n, characterized in that: include: Collect images of fiber optic adapters in real scenes, annotate the data, and preprocess the data set; Improvements are made based on the YOLOv8n-OBB model by introducing the MobileViTv3 module to optimize the backbone network; the GhostBlock module is introduced to optimize the neck network; and the Dynamic Head is used to improve the detection head structure. The improved YOLOv8n-OBB lightweight model is optimized, and Angle DFL Loss is introduced as the loss function; the dynamic label assignment strategy Dynamic ATSS is introduced. After the training is completed, the optimal weight model after training is retained; the trained model is subjected to experimental testing.
2. According to claim 1, the method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n is characterized in that: The labeled data refers to the use of the Roboflow tool to manually and accurately label the collected images according to the fiber optic adapter, the execution claw and 10 types of digital characters with a rotated rectangular box; the preprocessing refers to expanding the data set by using random rotation, random translation, random flipping, random cropping, random erasing, Gaussian noise, changing brightness and other data enhancement methods, and randomly dividing the data set into a training set, a validation set, and a test set in a ratio of 8:1:
1.
3. According to the method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 1, it is characterized in that: The step 2 is specifically as follows: integrating MobileViTv3 into the C2f module of the backbone network; integrating GhostBottleneck v2 into the C2f module of the neck network; and using Dynamic Head to improve the detection head structure.
4. The method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 3 is characterized in that: The C2f module of the MobileViTv3 integrated into the backbone network is specifically as follows: in Back Bone, the C2f modules of the third and ninth layers remain unchanged, and the bottleneck blocks in the C2f modules of the fifth and seventh layers are replaced with MobileViTv3. The improved module is called the C2f_MViTBv3 module.
5. The method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 3 is characterized in that: The Ghost Bottleneck v2 is integrated into the C2f module of the neck network as follows: in Neck, the standard bottleneck structure in all C2f modules is replaced with Ghost Bottleneck v2, and the improved module is called C2f_GhostBlockv2 module.
6. The method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 3 is characterized in that: The Dynamic Head improved detection head structure specifically includes: introducing an attention mechanism into the detection head, and replacing the original detection head with a dynamic detection head.
7. The method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 1, characterized in that: The Angle DFL Loss loss function is as follows: Angle DFL Loss discretizes the target angle into distribution points within a fixed range, and each angle value is mapped to a set of probability distributions. The distribution loss is obtained by calculating the difference between the predicted distribution and the target distribution. The final angle loss is normalized by the sum of the target scores as shown in formula (1):
8. The method for detecting rotating targets of lightweight optical fiber adapters based on improved YOLOv8n according to claim 1, characterized in that: The dynamic label assignment strategy Dynamic ATSS is specifically as follows: the prediction information is incorporated into the definition of positive and negative samples, the combined IoU is calculated by combining the IoU of the predicted bounding box and the IoU of the anchor box, and the label assignment strategy is dynamically adjusted based on this. The combined IoU of the two is defined as formula (2): CIoU=IoU pred +IoU anchor (2) The dynamic threshold is calculated using the mean and standard deviation of the combined IoU as shown in formula (3): T=μ CIoU +s CIoU (3)。
Citation Information
Patent Citations
Implementation method for SAR image rotation ship detection based on RCIoU loss
CN113033303A
Oil and gas station fire detection method, system, medium, equipment and terminal
CN116563762A
Traffic target identification method based on improved YOLOv8 model
CN117237915A
Fire detection method based on dynamic multi-scale attention network
CN117409359A
Method for detecting direction bounding box of maintenance part in real time based on YOLOv5-OBB
CN117593509A
Cited By
Mamb-YOLO-based semiconductor laser chip damage detection method and system
CN120543476A
Wafer defect detection method and system based on YOLO-Label comparison
CN121437520A
SIM card information extraction method and system based on rotating target detection and dynamic correction
CN121482805A