Fracture detection method and system based on improved loss function and lightweight attention
By improving the loss function and lightweight attention mechanism, the fracture detection method solves the problems of low accuracy and high computational cost in the existing technology, and realizes high-precision fracture detection in resource-constrained environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF ELECTRONICS SCI & TECH OF CHINA ZHONGSHAN INST
- Filing Date
- 2026-02-26
- Publication Date
- 2026-06-09
Smart Images

Figure CN122175891A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and in particular to a fracture detection method and system based on an improved loss function and lightweight attention. Background Technology
[0002] Fractures are one of the most common types of trauma in clinical practice, and their accurate diagnosis is crucial for subsequent treatment planning and prognostic assessment. X-ray images are widely used for initial screening and diagnosis of fractures due to their ease of acquisition, low cost, and relatively low radiation dose. However, in actual clinical settings, some fractures, especially early-stage or occult fractures, often present as small, elongated crack structures with low contrast, easily affected by bone overlap, imaging noise, and the complexity of anatomical structures, posing significant challenges to both manual image interpretation and automated analysis. Traditional methods often rely on edge detection, texture analysis, or manually designed features, but their performance is limited when faced with diverse bone structures, complex backgrounds, and minute cracks. Moreover, in the high-intensity, high-pressure environment of the emergency department, due to the lack of timely guidance from orthopedic specialists, doctors risk missing or misdiagnosing fractures; misdiagnosis of fractures accounts for 24% of all misdiagnoses in the emergency department. Currently, using deep learning models for automatic identification and localization of fracture areas in X-ray images has become an important direction for research and application. From a technical perspective, existing fracture detection methods can be mainly divided into two categories: two-stage detection methods and single-stage detection methods. Two-stage detection methods, exemplified by Faster R-CNN, employ multi-layer feature extraction and progressive filtering mechanisms to achieve relatively detailed modeling of fracture regions. Typical examples of single-stage detection methods include the YOLO series, RetinaNet, and Transformer-based detection models proposed in recent years. Some of these works enhance the model's ability to detect small fracture regions by introducing multi-scale feature fusion structures, attention mechanisms, or lightweight network modules. Furthermore, commonly used IOU-based bounding box loss functions (such as GIoU, DIoU, CIoU, etc.) primarily focus on static modeling of single geometric factors, making it difficult to adapt to complex target structures and accurately reflect the morphological consistency between predicted and ground truth bounding boxes. Summary of the Invention
[0003] To address the aforementioned technical problems, the present invention aims to provide a fracture detection method and system based on an improved loss function and lightweight attention, which can effectively improve the localization accuracy of fine and irregular bone fracture targets.
[0004] The first technical solution adopted in this invention is: a fracture detection method based on an improved loss function and lightweight attention, comprising the following steps: Acquire fracture image datasets and perform data preprocessing to construct preprocessed fracture image datasets; A fracture detection model is constructed by introducing a global attention mechanism and a bounding box regression loss function; The fracture detection model is used to detect fractures in the preprocessed fracture image dataset to obtain fracture detection results.
[0005] Furthermore, the fracture detection model specifically includes a backbone network, a neck network, and a detection head, wherein: The backbone network includes a first convolutional module, a first C3k2 module, a spatial pyramid pooling module, and a partial spatial attention module. The first convolutional module includes a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, and a fifth convolutional layer. The first C3k2 module includes a first C3k2 block, a second C3k2 block, a third C3k2 block, and a fourth C3k2 block. The neck network includes a feature concatenation module, a second C3k2 module, a feature upsampling module, a global attention mechanism module, and a second convolution module. The feature upsampling module includes a first feature upsampling layer and a second feature upsampling layer. The feature concatenation module includes a first feature concatenation layer, a second feature concatenation layer, a third feature concatenation layer, and a fourth feature concatenation layer. The second C3k2 module includes a fifth C3k2 block, a sixth C3k2 block, a seventh C3k2 block, and an eighth C3k2 block. The global attention mechanism module includes a first global attention layer, a second global attention layer, and a third global attention layer. The second convolution module includes a sixth convolution layer and a seventh convolution layer. The detection head includes a first detection head, a second detection head, and a third detection head.
[0006] Furthermore, the backbone network, the neck network, and the detection head are connected sequentially, wherein: In the backbone network, the first convolutional layer, the second convolutional layer, the first C3k2 block, the third convolutional layer, the second C3k2 block, the fourth convolutional layer, the third C3k2 block, the fifth convolutional layer, the fourth C3k2 block, the spatial pyramid pooling module, and the partial spatial attention module are connected in sequence. In the neck network, the first feature upsampling layer, the first feature splicing layer, the fifth C3k2 block, the second feature upsampling layer, the second feature splicing layer, the sixth C3k2 block, the first global attention layer, the sixth convolutional layer, the third feature splicing layer, the seventh C3k2 block, the second global attention layer, the seventh convolutional layer, the fourth feature splicing layer, the eighth C3k2 block, and the third global attention layer are connected in sequence; The output of the second C3k2 block is connected to the input of the second feature stitching layer, the output of the third C3k2 block is connected to the input of the first feature stitching layer, the output of the partial spatial attention module is connected to the input of the first feature upsampling layer and the input of the fourth feature stitching layer, the output of the sixth C3k2 block is connected to the input of the third feature stitching layer, the output of the first global attention layer is connected to the input of the first detection head, the output of the second global attention layer is connected to the input of the second detection head, and the output of the third global attention layer is connected to the input of the third detection head.
[0007] Furthermore, the bounding box regression loss function serves as the localization loss function of the fracture detection model, used to measure the geometric consistency between the predicted bounding box output by the detection head and the true bounding box in terms of position, scale, and shape. The bounding box regression loss function includes gating proportional constraints, fuzzy perception compensation, and sample quality discrimination, wherein: The gating scaling constraint includes a scaling constraint term and a distance weighting term. The gating scaling constraint is used to constrain the shape consistency between the predicted bounding box and the ground truth bounding box at the geometric level, where the expression is: ; ; In the above formula, Indicates the proportional constraint term. This represents the distance-weighted term. This represents the aspect ratio of the longer side to the wider side of the actual bounding box. , These represent the weighting coefficients for the horizontal and vertical directions, respectively. This represents the diagonal distance between the smallest bounding box and the predicted box. This represents the gated term calculated using the sigmoid function. This represents the morphological difference term after normalization. Indicates the geometric center coordinates of the prediction box. Represents the geometric center coordinates of the true bounding box; The fuzzy perception compensation is used to adaptively reduce the morphological penalty of samples with moderate matching quality, and its expression is: ; ; In the above formula, Indicates the proportional constraint term. This represents the distance-weighted term. This represents the morphological penalty term after compensation. This represents the global adjustment weight of the proportional constraint term. Indicates intersection, union, and ratio. This represents the comprehensive geometric penalty term used in the above geometric error calculation. Indicates the basic loss item; The sample quality differentiation is used to integrate overlap quality and morphological consistency information to assign differentiated regression weights to different samples. The expression for this weighting is: ; In the above formula, This represents the sample quality discrimination loss function. This represents the basic weights that distinguish high-quality samples. This represents the basic loss item.
[0008] Furthermore, the step of detecting the preprocessed fracture image dataset based on the fracture detection model to obtain the fracture detection results specifically includes: The preprocessed fracture image dataset is input into the fracture detection model; Based on the backbone network of the fracture detection model, feature extraction processing is performed on the preprocessed fracture image dataset to obtain multi-scale fracture image features. Based on the neck network of the fracture detection model, feature fusion processing is performed on the multi-scale fracture image features to obtain the fused multi-scale fracture image features. The detection head based on the fracture detection model performs fracture feature detection on the fused multi-scale fracture image features to obtain fracture detection results.
[0009] Furthermore, the step of extracting features from the preprocessed fracture image dataset using the backbone network based on the fracture detection model to obtain multi-scale fracture image features specifically includes: The preprocessed fracture image dataset is input into the backbone network of the fracture detection model; Based on the first convolutional module of the backbone network, edge texture information and high-level semantic information are extracted from the preprocessed fracture image dataset to obtain multi-scale feature maps. Based on the first C3k2 module of the backbone network, the multi-scale feature map is segmented and the information flow is optimized to obtain a multi-scale resolution feature map. Based on the spatial pyramid pooling module of the backbone network, the receptive field feature is enlarged to obtain the expanded multi-scale resolution feature map. Based on the partial spatial attention module of the backbone network, the weights of the expanded multi-scale resolution feature map are adaptively adjusted to obtain multi-scale fracture image features.
[0010] Furthermore, the step of using the neck network based on the fracture detection model to perform feature fusion processing on multi-scale fracture image features to obtain fused multi-scale fracture image features specifically includes: Multiscale fracture image features are input into the neck network of the fracture detection model; Based on the feature upsampling module of the neck network, the multi-scale fracture image features are upsampled to obtain the upsampled multi-scale fracture image features. Based on the feature stitching module of the neck network, feature stitching processing is performed on the upsampled multi-scale fracture image features to obtain the stitched multi-scale fracture image features. Based on the second C3k2 module of the neck network, the spliced multi-scale fracture image features are optimized to obtain optimized multi-scale fracture image features. The global attention mechanism module and the second convolution module based on the neck network are used to perform weighted adjustment and fusion of the complementary relationship between fine-grained location information and high-level semantic information on the optimized multi-scale fracture image features, so as to obtain the fused multi-scale fracture image features.
[0011] The second technical solution adopted in this invention is: a fracture detection system based on an improved loss function and lightweight attention, comprising: The first module is used to acquire fracture image datasets and perform data preprocessing to construct preprocessed fracture image datasets. The second module is used to introduce a global attention mechanism and a bounding box regression loss function to build a fracture detection model. The third module is used to detect fractures in the preprocessed fracture image dataset based on the fracture detection model, and obtain fracture detection results.
[0012] The beneficial effects of the method and system of this invention are as follows: This invention acquires a fracture image dataset and performs data preprocessing to construct a preprocessed fracture image dataset; further, it introduces a global attention mechanism and a bounding box regression loss function to construct a fracture detection model. The bounding box regression loss function introduces gating proportional constraints and direction-aware center distance penalties during the regression process, enabling the regression penalty to adaptively allocate in different directions according to the shape and proportion of the real target. This applies stricter geometric constraints in the short axis direction of the fracture target and maintains reasonable tolerance in the long axis direction, effectively improving the localization accuracy of fine and irregular fracture targets. Furthermore, a global attention mechanism is introduced in the feature fusion stage to enhance the global consistency and discriminative power of fracture-related features in multi-scale space. Finally, the fracture detection model is used to detect the preprocessed fracture image dataset to obtain fracture detection results, effectively improving the localization accuracy of fine and irregular fracture targets. Attached Figure Description
[0013] Figure 1 This is a flowchart of the steps of the fracture detection method based on the improved loss function and lightweight attention of the present invention; Figure 2 This is a block diagram of the fracture detection system based on an improved loss function and lightweight attention according to the present invention. Figure 3 This is a schematic diagram of the overall network architecture of MAG-YOLO provided in a specific embodiment of the present invention; Figure 4 This is a schematic diagram of the MorphAware-IoU loss function algorithm provided in a specific embodiment of the present invention; Figure 5 This is a schematic diagram of the coordinates of the ground truth bounding box and the predicted bounding box provided in a specific embodiment of the present invention; Figure 6 This is a schematic diagram of the medical image preprocessing algorithm provided in a specific embodiment of the present invention; Figure 7 This is a schematic diagram of the detection results of the MAG-YOLO network model provided in a specific embodiment of the present invention on fracture images at multiple locations.
[0014] Figure reference numerals: 1. First convolutional layer; 2. Second convolutional layer; 3. First C3k2 block; 4. Third convolutional layer; 5. Second C3k2 block; 6. Fourth convolutional layer; 7. Third C3k2 block; 8. Fifth convolutional layer; 9. Fourth C3k2 block; 10. Spatial pyramid pooling module; 11. Partial spatial attention module; 12. First feature upsampling layer; 13. First feature concatenation layer; 14. Fifth C3k2 block; 15. Second feature upsampling layer; 16. Second feature concatenation layer; 17. Sixth C3k2 block; 18. First global attention layer; 19. Sixth convolutional layer; 20. Third feature concatenation layer; 21. Seventh C3k2 block; 22. Second global attention layer; 23. Seventh convolutional layer; 24. Fourth feature concatenation layer; 25. Eighth C3k2 block; 26. Third global attention layer; 27. First detection head; 28. Second detection head; 29. Third detection head. Detailed Implementation
[0015] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments. The step numbers in the following embodiments are only for ease of explanation and do not limit the order of the steps. The execution order of each step in the embodiments can be adapted according to the understanding of those skilled in the art.
[0016] First, the technical terms used in the embodiments of the present invention will be explained: 1) Intersection over Union (IoU): This is an algorithm that calculates the proportion of overlap between different images. It is frequently used in object detection or semantic segmentation tasks in deep learning. In object detection tasks, after obtaining the predicted bounding box positions from the model output, the IoU between the output box and the ground truth box can also be calculated. In this case, the value of this box ranges from 0 to 1, where 0 indicates that the two boxes do not intersect, and 1 indicates that the two boxes exactly overlap.
[0017] 2) Bounding Box Regression (BBR): Bounding box regression is a commonly used technique in object detection tasks to improve and fine-tune object localization. Bounding box regression predicts a more accurate object region by learning the deviation between the ground truth bounding box and the candidate bounding box.
[0018] 3) Bounding Box Regression Loss Function (BBR loss): The loss function for object detection tasks consists of two parts: Classification Loss and BBox Regression Loss. Commonly used BBox Regression Loss functions include CIoU, GIoU, and EIoU loss functions calculated based on IoU.
[0019] 4) SPPF: Spatial Pyramid Fast Pooling Layer. It enhances the model's adaptability to multi-scale targets by fusing features from different receptive fields through multi-scale pooling operations.
[0020] 5) C2PSA: A high-level module for enhancing feature extraction, combining the CSP (Cross Stage Partial) structure and the PSA (Pyramid Squeeze Attention) attention mechanism to improve multi-scale feature extraction capabilities.
[0021] 6) Upsample: Feature upsampling layer. It restores the feature map resolution through bilinear interpolation, aligning the spatial dimensions of shallow and deep features.
[0022] 7) Concat: Feature concatenation layer. Concatenates feature maps from different levels along the channel dimension, integrating localization details and semantic information.
[0023] 8) Detect: YOLO11 native detection head structure.
[0024] There are still some shortcomings in the related technologies, such as: 1) Existing fracture detection methods have low localization accuracy and insufficient detection stability in the case of minor bone fractures. Existing technologies generally adopt a general target detection framework and its supporting bounding box regression strategy. This type of regression mechanism is mainly designed for conventional targets and is difficult to adapt to the slender, irregular and blurred structural features of bone fracture targets. It is easy for the regression accuracy to fluctuate during the training process, which in turn affects the consistency and reliability of the detection results.
[0025] 2) Existing technologies lack effective differentiation between samples of varying quality, easily leading to false positives and, in real-world environments, high rates of misdiagnosis. Current detection models typically employ a uniform optimization strategy for samples of different matching qualities, lacking effective control mechanisms for low-quality or moderately matched samples. This causes the model to misclassify non-cracked structures as cracked areas in complex contexts, increasing the false positive rate and impacting clinical application value. Furthermore, there is currently limited research on improving the misdiagnosis rate.
[0026] 3) Some high-precision fracture detection methods are complex in structure and computationally expensive, which is not conducive to practical deployment. To improve detection performance, some existing technologies enhance feature representation by introducing multi-level complex structures or a large number of attention modules. However, these methods often result in a large number of model parameters and high computational overhead, making it difficult to run efficiently on resource-constrained medical terminals or edge devices.
[0027] 4) Existing feature enhancement methods lack effective designs specifically for bone fracture features, resulting in insufficient adaptability. Most existing methods employ general-purpose feature enhancement techniques that fail to adequately consider the differences in bone fracture representation across different scale feature maps. This can easily lead to uneven or redundant feature enhancement, affecting overall detection performance.
[0028] 5) Existing technologies have limited generalization ability across different fracture types and datasets. While existing fracture detection methods perform well on specific bone sites or datasets, their performance fluctuates significantly when applied across different sites and datasets, making it difficult to meet the requirements for versatility and robustness in clinical scenarios.
[0029] Based on this, this embodiment of the invention designs a BBR loss algorithm, MorphAware-IoU, based on morphological consistency perception and sample quality discrimination, which can effectively improve the localization stability of bone fracture targets and effectively suppress false detections. Simultaneously, combined with a lightweight feature enhancement structure, Global Attention Mechanism (GAM), it strengthens the effective representation of the crack region at multi-scale feature levels, thereby achieving robust detection for different fracture types and imaging scenarios without significantly increasing model complexity and computational overhead. This embodiment can improve detection accuracy and generalization ability while maintaining model lightweightness, and is suitable for various fracture detection application scenarios. This embodiment constructs a lightweight YOLO11n model, MAG-YOLO, for fracture detection based on the MorphAware-IoU loss function and Global Attention Mechanism (GAM), enabling the model to enhance crack representation ability at the feature level and achieve more robust geometric optimization at the regression level, thus forming a fracture detection framework that combines global information interaction and morphological sensitivity.
[0030] Reference Figure 1 This invention provides a fracture detection method based on an improved loss function and lightweight attention, the method comprising the following steps: S100. Obtain the fracture image dataset and perform data preprocessing to construct the preprocessed fracture image dataset. S200: A fracture detection model is constructed by introducing a global attention mechanism and a bounding box regression loss function; In this embodiment, the fracture detection model specifically includes a backbone network, a neck network, and a detection head, wherein: The backbone network includes a first convolutional module, a first C3k2 module, a spatial pyramid pooling module, and a partial spatial attention module. The first convolutional module includes a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, and a fifth convolutional layer. The first C3k2 module includes a first C3k2 block, a second C3k2 block, a third C3k2 block, and a fourth C3k2 block. Specifically, in the backbone network, the first convolutional layer 1, the second convolutional layer 2, the first C3k2 block 3, the third convolutional layer 4, the second C3k2 block 5, the fourth convolutional layer 6, the third C3k2 block 7, the fifth convolutional layer 8, the fourth C3k2 block 9, the spatial pyramid pooling module 10, and the partial spatial attention module 11 are connected in sequence.
[0031] The neck network includes a feature concatenation module, a second C3k2 module, a feature upsampling module, a global attention mechanism module, and a second convolution module. The feature upsampling module includes a first feature upsampling layer and a second feature upsampling layer. The feature concatenation module includes a first feature concatenation layer, a second feature concatenation layer, a third feature concatenation layer, and a fourth feature concatenation layer. The second C3k2 module includes a fifth C3k2 block, a sixth C3k2 block, a seventh C3k2 block, and an eighth C3k2 block. The global attention mechanism module includes a first global attention layer, a second global attention layer, and a third global attention layer. The second convolution module includes a sixth convolution layer and a seventh convolution layer. Specifically, in the neck network, the first feature upsampling layer 12, the first feature splicing layer 13, the fifth C3k2 block 14, the second feature upsampling layer 15, the second feature splicing layer 16, the sixth C3k2 block 17, the first global attention layer 18, the sixth convolutional layer 19, the third feature splicing layer 20, the seventh C3k2 block 21, the second global attention layer 22, the seventh convolutional layer 23, the fourth feature splicing layer 24, the eighth C3k2 block 25, and the third global attention layer 26 are connected in sequence.
[0032] The detection head includes a first detection head 27, a second detection head 28, and a third detection head 29.
[0033] Specifically, the output of the second C3k2 block is connected to the input of the second feature stitching layer, the output of the third C3k2 block is connected to the input of the first feature stitching layer, the output of the partial spatial attention module is connected to the input of the first feature upsampling layer and the input of the fourth feature stitching layer, the output of the sixth C3k2 block is connected to the input of the third feature stitching layer, the output of the first global attention layer is connected to the input of the first detection head, the output of the second global attention layer is connected to the input of the second detection head, and the output of the third global attention layer is connected to the input of the third detection head.
[0034] S300. Based on the fracture detection model, the preprocessed fracture image dataset is detected to obtain fracture detection results.
[0035] S310. Input the preprocessed fracture image dataset into the fracture detection model; S320. Based on the backbone network of the fracture detection model, feature extraction processing is performed on the preprocessed fracture image dataset to obtain multi-scale fracture image features. Specifically, the preprocessed fracture image dataset is input into the backbone network of the fracture detection model; based on the first convolutional module of the backbone network, edge texture information and high-level semantic information are extracted from the preprocessed fracture image dataset to obtain multi-scale feature maps; based on the first C3k2 module of the backbone network, the multi-scale feature maps are segmented and information flow optimized to obtain multi-scale resolution feature maps; based on the spatial pyramid pooling module of the backbone network, the receptive field feature maps of the multi-scale resolution feature maps are enlarged to obtain expanded multi-scale resolution feature maps; based on the partial spatial attention module of the backbone network, the expanded multi-scale resolution feature maps are subjected to adaptive weight adjustment to obtain multi-scale fracture image features.
[0036] In this embodiment, as Figure 3 As shown, the overall structure of the MAG-YOLO network consists of three parts: the backbone, the neck, and the head. The backbone is responsible for multi-scale feature extraction; the neck, located between the backbone and the head, is responsible for multi-scale feature fusion; and the head is the decision-making part of the object detection model, responsible for generating the final detection result.
[0037] First, the backbone network is used to extract multi-level features from the input fracture images. Through multi-layer convolutional units and feature encoding modules, it progressively downsamples to obtain multi-scale feature maps containing edge texture information and high-level semantic information, thus constructing a hierarchical multi-scale feature representation. The core of the backbone network's feature extraction is the C3k2 module, which optimizes the information flow in the network by segmenting the feature maps and applying a series of smaller kernel (3*3) convolutions. The 3*3 convolutions allow the module to perform more efficient computation while preserving the model's ability to extract basic features from the image. As the network depth increases, the backbone network sequentially forms multi-level feature outputs, including medium-to-high resolution feature maps for small-scale object detection and low-resolution, high-semantic feature maps for medium- and large-scale object detection. Furthermore, a faster Spatial Pyramid Pooling-Fast (SPPF) module is introduced in the high-level feature stage of the backbone network to expand the effective receptive field of the features without significantly increasing computational complexity, thereby improving the model's ability to model large targets and complex background context information. Simultaneously, by introducing a Cross-Stage Partial with Spatial Attention (C2PSA) module, higher weights are assigned to key spatial regions in high-level features, thereby improving the ability to distinguish between target and background regions. After processing by the aforementioned backbone network, feature maps of at least three different scales are output, providing a foundation for subsequent multi-scale feature fusion.
[0038] S330. Based on the fracture detection model, a neck network is used to perform feature fusion processing on multi-scale fracture image features to obtain fused multi-scale fracture image features. Specifically, multi-scale fracture image features are input into the neck network of the fracture detection model; based on the feature upsampling module of the neck network, the multi-scale fracture image features are upsampled to obtain upsampled multi-scale fracture image features; based on the feature stitching module of the neck network, the upsampled multi-scale fracture image features are stitched together to obtain stitched multi-scale fracture image features; based on the second C3k2 module of the neck network, the stitched multi-scale fracture image features are optimized to obtain optimized multi-scale fracture image features; based on the global attention mechanism module and the second convolution module of the neck network, the optimized multi-scale fracture image features are weighted and fused by the complementary relationship between fine-grained positional information and high-level semantic information to obtain fused multi-scale fracture image features.
[0039] In this embodiment, the neck network is used to fuse multi-scale features output by the backbone network. It achieves multi-scale information interaction through a bidirectional feature transfer mechanism (top-down and bottom-up), and introduces a Global Attention Mechanism (GAM) at several key feature fusion nodes. GAM globally models and weights the channel and spatial dimensions of the features, enabling the network to more accurately focus on the local structural features of the fracture region and its surroundings during multi-scale fusion. This effectively enhances the fracture edge and detail information while suppressing background interference, improving the consistency and discriminative power of the fused features across different scales. Specifically, in the top-down feature fusion process, high-level features are upsampled and concatenated with low-level features of the corresponding scale. Then, the global attention mechanism jointly models the importance of the fused features in the channel and spatial dimensions, adaptively strengthening feature responses related to the target region and suppressing redundant or noisy information. In the bottom-up feature fusion process, low-level fused features are downsampled and fused again with high-level features. The global attention mechanism weights the complementary relationship between fine-grained location information and high-level semantic information to avoid interference from invalid details on the high-level semantic expression.
[0040] S340, a detection head based on a fracture detection model, performs fracture feature detection on the fused multi-scale fracture image features to obtain fracture detection results.
[0041] In this embodiment, the detection head network constructs multiple detection branches based on multi-scale feature maps enhanced by GAM, which are used to output the bounding box position, category information, and confidence score of the bone fracture target. The detection head operates on fused feature maps of different scales, corresponding to the detection requirements of small-scale, medium-scale, and large-scale targets. For each scale feature, the detection head completes target category probability prediction and target position parameter regression through parallel prediction branches, thereby outputting the detection result at the corresponding scale. During the training phase, the predicted bounding box output by the target position regression branch and the corresponding ground truth bounding box are jointly input into the MorphAware-IoU loss function designed in this invention. This function measures the geometric consistency between the predicted bounding box and the ground truth bounding box in terms of position, scale, and shape, and participates in the joint optimization of the overall model loss function as a core component of the localization loss. Here, this invention uses MorphAware-IoU as the bounding box regression loss function. Through morphological consistency constraints and sample quality differentiation mechanisms, it performs more stable geometric modeling of slender, irregular, and blurred-boundary bone fracture targets, reduces excessive penalty for moderately matched samples, and reduces false detections. By combining the above-mentioned synergistic design of structure and regression mechanism, this invention achieves high-precision and stable detection of multi-scale and multi-morphological bone fracture targets without significantly increasing model complexity and computational cost.
[0042] Furthermore, the bounding box regression loss function in the embodiments of the present invention will be explained in detail: In this embodiment, the loss function for the fracture detection task consists of localization loss, confidence loss, and classification loss. Localization loss is the most complex and crucial part of the model's loss function, directly determining whether the model can accurately predict the target's position and size. Essentially, it predicts a bounding box that surrounds the target object as tightly as possible. We designed the MorphAware-IoU loss function as the core component of the localization loss function in the detection task. This function measures the geometric consistency between the predicted bounding box and the ground truth bounding box and provides supervised constraints for bounding box regression. Figure 5 As shown, this significantly improves target localization accuracy and regression stability while maintaining classification performance. MorphAware-IoU can be viewed as a triple adaptive optimization system, including gating proportional constraints, fuzzy perception compensation, and sample quality discrimination mechanisms, to achieve more stable bounding box regression with morphological understanding capabilities. The gating proportional constraints and fuzzy perception compensation mechanisms are implemented as penalty terms in the loss function, while the sample quality discrimination mechanism is implemented as the overall weight of the loss function.
[0043] Regarding the gating ratio constraint mechanism: Gated proportional constraints include proportional constraint terms. and distance weighted terms This embodiment utilizes the sigmoid function to construct a gating function to constrain morphological differences. It enhances the response only when the predicted bounding box and the ground truth bounding box are similar in shape and applies a penalty, thereby suppressing the perturbation of training dynamics by long-tailed samples and abnormally proportioned objects. This structured gradient gating is particularly effective in the early stages of training, significantly reducing gradient oscillations between samples and improving the predictability of the optimization path. First, the aspect ratio of the long side to the width of the predicted bounding box is calculated. The ratio of the longer side to the wider side of the true frame (GT box) Next, a sigmoid function is used to design a gating function. 2.0 is an empirical threshold: when the aspect ratio of the actual bounding box is close to or greater than 2, the gate increases rapidly, indicating that "it is indeed a slender target, and the proportional constraint should be stronger." Therefore, a proportional penalty term is added based on the proportional constraint, defined by the following formula: ; ; ; ; ; in and These represent the width and height of the prediction box, respectively. and These represent the length and width of the GT box, respectively. This represents the sigmoid function. This represents a non-zero minimum value.
[0044] For slender targets such as bone fractures, the tolerance for position along the long axis is generally higher than that along the short axis. If a uniform weight is applied to the horizontal and vertical directions in the center point offset penalty, it can easily lead to a significant shift in the short side of the model, thus compromising the geometric consistency of the crack. Therefore, this invention introduces a direction weighting coefficient related to the target's shape, allowing the center point offset penalty to adaptively adjust to the shape of the actual target. The Distance constraint ensures that when penalizing center point offset, the offset along the short side of the bounding box is penalized more severely, as defined in the following formula: ; ; in This is a scaling factor, related to the scale of the targets in the dataset. and These are the weighting coefficients for the horizontal and vertical directions, respectively. Their values are related to the shape of the GT box. When the real target exhibits a distinctly elongated shape (such as...), the weighting coefficients will be adjusted accordingly. >> The above definition will give a larger weight to the shorter side direction, thus imposing a stronger constraint on the center offset of the shorter side direction during the regression process. After obtaining the direction weights, this invention performs a weighted calculation of the offset distance between the center points of the predicted box and the ground truth box, defining the distance constraint term as: ; in, This is the diagonal distance between the ground truth bounding box and the predicted bounding box. This distance constraint term, through orientation weighting, makes the model more strictly constrain the offset along the short axis of the target during the regression process, while maintaining a relatively smooth penalty along the long axis, thus better conforming to the geometric characteristics of slender bone fracture targets.
[0045] Proportional gating constraints Used to limit the consistency between the overall shape of the predicted bounding box and the shape of the ground truth bounding box, distance weighting term Used to limit the offset behavior of the predicted box center in different directions; together they constitute a morphology-aware geometric constraint mechanism, enabling the bounding box regression process to simultaneously consider the target's proportional structure and spatial distribution characteristics, thereby significantly improving the localization stability of slender, irregular bone fracture targets.
[0046] For fuzzy perception compensation mechanisms: Small targets or blurry samples may cause large gradient fluctuations, so we designed a blur compensation term. By adaptively adjusting the morphological penalty term using a non-linear scaling function, protection is provided for small targets and blurred samples, and gradient stability and oscillations are ensured during model training. First, considering the morphological differences between the predicted and ground truth bounding boxes, morphological difference terms in the width and height directions are defined as follows: ; ; Furthermore, to account for the small scale of the bone fracture target, the area of the true target is defined as... The relative area is obtained by area normalization. : ; ; Based on this, area sensing signals are introduced. Meanwhile, to characterize the uncertainty between the predicted bounding box and the ground truth bounding box in the medium-quality matching region, an IoU-based fuzzy mask is introduced. : ; ; in, This is a fuzziness adjustment factor used to control the width of the fuzziness compensation range, ensuring that the IoU between the predicted bounding box and the ground truth bounding box is close to a preset center value. At that time, blur mask Achieving a larger value. Based on the area-sensing signal and fuzzy mask described above, a fuzzy compensation factor is constructed. The morphological penalty term is corrected by the fuzzy compensation factor to obtain the compensated morphological penalty term. : ; ; in This refers to the global adjustment weights for fuzziness compensation. Through the above design, when the target scale is small and the predicted bounding box and the ground truth bounding box are in a moderate matching state, the morphological penalty term will be adaptively weakened, thereby avoiding excessive penalty for fuzzy samples. Thus, the basic loss function is constructed as follows: ; ; in It is the global adjustment weight of the proportional constraint. By introducing the above-mentioned fuzzy compensation mechanism, this invention can improve the regression stability of fuzzy, small-scale bone fracture targets while maintaining the effectiveness of morphological constraints, and reduce unstable fluctuations during training.
[0047] Regarding the sample quality differentiation mechanism: In scenarios with drastic changes in geometric features, evaluating anchor box quality using outlier-based IOU is impractical. Therefore, in the loss function of this invention, we implement "fusion of geometric consistency and adaptive morphological perception." This mechanism adaptively adjusts the weights of samples in the regression loss based on their geometric matching quality and morphological features, dynamically distinguishing sample importance according to the degree of morphological matching. First, for the morphological features of the ground truth bounding box, we define the target's thinness measure. And construct morphological sensing signals using the sigmoid function. : ; ; Based on this, morphological signals and scale-related signals are fused to construct a geometric consistency enhancement factor. : ; ; in Therefore Weights that differentiate high-quality samples based on fundamental principles; and These are the morphological weighting coefficient and the area weighting coefficient, respectively, used to adjust the degree of influence of different geometric factors on sample quality assessment; control and The mixing coefficients between them yield the loss function: ; Through the above-mentioned sample quality differentiation mechanism, the present invention can dynamically adjust the optimization weights of samples according to their morphological matching degree and geometric consistency during the training process, so that samples with high morphological consistency and clear structural features can play a greater role in regression optimization, while suppressing the interference of low-quality or uncertain samples on model training, thereby improving the regression stability and detection accuracy in bone fracture detection tasks.
[0048] Therefore, in the bounding box regression loss function of this invention, three mechanisms—gating proportional constraint, fuzzy perception compensation, and sample quality discrimination—work synergistically to address the characteristics of bone fracture targets—such as slender shapes, blurred boundaries, and high matching uncertainty. Specifically, the gating proportional constraint constrains the morphological consistency between the predicted and ground truth bounding boxes at the geometric level. Through proportional gating and orientation-weighted center distance penalties, the regression process maintains stricter positioning constraints along the critical short axis, providing a stable geometric basis for overall optimization. Furthermore, the fuzzy perception compensation mechanism adaptively weakens the morphological penalty term for medium-quality and small-scale bone fracture samples, mitigating excessive penalties caused by blurred boundaries or labeling uncertainty, thereby smoothing the regression gradient and improving the continuity and stability of the training process. Finally, the sample quality discrimination mechanism integrates basic overlap quality and morphological consistency information, dynamically adjusting the contribution of different samples to the regression loss. This ensures that samples with high structural matching and clear geometric features receive higher weights during optimization, while reducing the interference of low-quality or uncertain samples on model updates. Through the synergistic design of the above three mechanisms, this invention achieves an organic unity of geometric constraints, fuzzy compensation, and sample importance allocation in the bounding box regression process. While ensuring training stability, it significantly improves the localization accuracy of minor bone fracture targets and effectively suppresses false detections.
[0049] In the feature modeling stage of this invention, to address the issues of bone fracture targets being easily disturbed and having insufficient local texture response in complex skeletal backgrounds, a Global Attention Mechanism (GAM) is introduced to enhance multi-scale features. The core idea of GAM is to simultaneously model the global dependencies of features in both channel and spatial dimensions, enabling the network to comprehensively consider the semantic associations between different channels and the contextual relationships between spatial locations during feature fusion, thereby avoiding the problem of limited receptive fields caused by relying solely on local convolutions.
[0050] Based on this idea, in the feature modeling and fusion process of this invention, to address the common problems of low texture contrast, discontinuous boundaries, and susceptibility to interference from complex skeletal structures in medical images of bone fracture targets, a Global Attention Mechanism (GAM) is introduced as a key feature enhancement unit. Traditional convolutional feature extraction methods mainly rely on local receptive fields. Although they can capture local texture and edge information, in bone fracture detection scenarios, cracks are often long, thin, and discontinuous. Their discriminative features not only depend on local texture but also highly depend on cross-regional contextual relationships. Therefore, it is difficult to form a stable and discriminative feature representation based solely on local convolution. Based on the above understanding, this invention introduces GAM to establish global dependencies of features in the channel and spatial dimensions. Through the channel attention mechanism, the importance of different semantic channels is modeled holistically, giving higher response weights to feature channels related to the bone fracture structure while suppressing redundant channels related to background skeletal texture. Furthermore, through the spatial attention mechanism, the correlation between different spatial locations is modeled globally, enabling the network to more accurately focus on the crack region and its key contextual locations in complex backgrounds. Furthermore, this invention places GAM in the feature fusion stage rather than simply the backbone feature extraction stage, allowing it to act on fused features that have already completed multi-scale information interaction. This results in a unified and consistent enhancement effect across features at different scales, avoiding information bias caused by attention modulation only at a single scale or local level. Through this design, GAM enables the network to obtain stronger global perception and structural consistency in the multi-scale feature space without significantly increasing the model's computational complexity. This provides a more stable, clear, and discriminative feature foundation for subsequent bounding box regression and detection decisions, thereby improving the robustness and reliability of bone fracture detection in complex scenarios.
[0051] Furthermore, in the bone fracture detection framework of this invention, the MorphAware-IoU regression optimization mechanism and the Global Attention (GAM) mechanism work synergistically at the feature modeling and geometric regression levels. GAM is responsible for globally enhancing fracture-related information at the feature level, while MorphAware-IoU performs morphological consistency constraints and stability optimization on the geometric prediction results corresponding to the enhanced features at the regression level. Specifically, GAM, through global modeling of channel and spatial dimensions, makes the network more prominent in multi-scale fusion features regarding fracture edges, orientations, and their contextual structure, thus providing a clearer and more discriminative feature representation basis for bounding box regression. Based on this, MorphAware-IoU, through mechanisms such as gating ratio constraints, fuzzy perception compensation, and sample quality differentiation, performs morphologically perceptual geometric optimization on the predicted boxes generated based on the aforementioned features, enabling the regression process to fully utilize the structural information enhanced by GAM and avoid instability or excessive penalty on slender, fuzzy fracture samples. The synergistic effect of the two forms a closed loop between feature enhancement and regression optimization: GAM improves the separability and consistency of crack-related features, while MorphAware-IoU transforms this feature advantage into a more stable localization result that conforms to the morphological characteristics of bone cracks. Thus, without significantly increasing the complexity of the model, it can simultaneously improve detection accuracy, training stability and effectively suppress false positives.
[0052] Finally, the implementation process of the embodiments of the present invention will be described in conjunction with the accompanying drawings: 1) Dataset preparation and preprocessing: Choose a publicly available dataset relevant to fracture detection, such as the GRAZPEDWRI-DX dataset (X-ray image dataset). The dataset can be in non-YOLO format; simply convert the labels to YOLO format. The dataset directory should contain two main folders: images (for storing images) and labels (for storing annotation files). Each folder should be further divided into training, validation, and test subfolders, corresponding to the training set, validation set, and test set, respectively, with a recommended ratio of 7:2:1. Considering that fractures in X-ray images often appear small, with low contrast and blurred structures, the model is easily affected by imaging noise, brightness differences, and shooting angle shifts during training. To improve the model's robustness to bone fracture structures under diverse imaging conditions, it is recommended to preprocess the original X-ray images using lightweight enhancement methods such as random rotation, translation, and brightness / contrast perturbation to improve image quality, and to utilize data augmentation techniques to expand the training set. This not only increases the diversity of bone fracture samples but also mitigates training bias caused by differences in imaging conditions, thereby giving the model stronger generalization ability in real clinical scenarios.
[0053] Specifically, such as Figure 6As shown, the X-ray images are first scaled and normalized to reduce distribution shifts caused by imaging differences. Then, lightweight enhancement methods such as random rotation, translation, and brightness / contrast perturbation are employed to improve the model's robustness to different shooting conditions and diverse bone fracture morphologies. Finally, Gaussian blurring is used to reduce local noise and soft tissue texture interference; and adaptive histogram equalization is combined to enhance local contrast, thereby highlighting the edges of the bone cortex and fine crack structures. Our processing strategies all remain within a small range of variation to avoid disrupting the original morphology of the bone fracture.
[0054] 2) Development environment configuration and dependency library installation: We employed a high-performance computing environment to ensure experimental efficiency, equipped with an Intel(R) Xeon(R) Gold 5218 processor (32 cores, 64 threads) and four NVIDIA Quadro RTX 6000 GPUs (24GB VRAM), running on Ubuntu 20.04. The deep learning framework chosen was PyTorch, and CUDA technology was used to accelerate model training and inference processes, thereby improving computational efficiency and data processing capabilities. Necessary Python libraries, such as Ultralytics, TorchVision, NumPy, and OpenCV-Python, were installed via pip.
[0055] 3) Model structure definition and construction: First, the proposed MorphAware-IoU loss function is defined in the loss function-related module and introduced into the bounding box regression loss calculation process, making it participate in model training as part of the location regression loss. Simultaneously, the GAM module is implemented in the network module definition file, ensuring that its required basic operators and dependent modules are available. Subsequently, the newly defined modules are registered during the model construction and parsing phase, enabling the network structure parsing process to correctly identify and instantiate the attention modules, thereby achieving effective integration of the MorphAware-IoU loss function and the GAM module in the overall detection network. Finally, based on the provided network structure and module definitions, a MAG-YOLO model configuration file is written, clearly defining the type, parameters, and connection relationships of each layer, and constructing a fracture detection model.
[0056] Among them, such as Figure 4As shown, the overall process of the MorphAware-IoU regression algorithm proposed in this invention is as follows: First, the basic IoU is calculated based on the predicted bounding box and the ground truth bounding box. Then, a direction-aware center distance constraint is introduced to apply geometric penalties related to the target shape to the positioning offset along different axes. Subsequently, a gating ratio constraint is used to adjust the aspect ratio difference between the predicted and ground truth bounding boxes, enabling the regression process to adapt to the morphological features of slender targets such as bone fractures. Furthermore, for samples with blurred bone fracture boundaries and small scale, a fuzzy perception compensation mechanism is introduced to adaptively weaken the morphological penalty for samples with moderate matching quality, ensuring the smoothness of the optimization process. Further, a sample quality differentiation mechanism integrates overlap quality and morphological consistency information to assign differentiated regression weights to different samples. Finally, the geometric penalties and sample weights are applied together to the IoU regression loss to achieve stable, robust, and morphologically consistent bounding box regression optimization for targets with minute bone fractures. We use LearnableWiseWeight to achieve automatic learning of some parameters, allowing these parameters to be automatically optimized during training.
[0057] 4) Model training and validation: Load Configuration and Weights: Using the YOLO class in the Ultralytics framework, load the YAML configuration file written in step three. Optional loading of pre-trained YOLO11n weights can accelerate convergence.
[0058] Training parameters were configured as follows: This experiment involved 100 training rounds. The training configuration used a pixel input resolution of 1024×1024 (imgsz) and a batch size of 64. The optimizer selected was Stochastic Gradient Descent (SGD), which is known for its convergence stability and strong generalization. The initial learning rate was set to 0.01. Mosaic and MixUp data augmentation were disabled to reduce the interference of complex scenes on the learning of basic features, allowing the model to focus more on the essential features of fractures and fissures. Data loading was performed using 8 threads during the training process.
[0059] Start training: Create a new training script named train.py for training, specifying the path to the dataset configuration file (data='datafiles / grazpedwri-dx.yaml'). During training, use TensorBoard to monitor the changes in the loss function, accuracy metrics, etc., to ensure the model converges normally.
[0060] Model Evaluation: After training, the best-performing weight file (e.g., best.pt) was used for evaluation on the test set. This experiment used six standard metrics in the field of object detection to comprehensively evaluate model performance: mAP@0.5, mAP@0.5:0.95, precision (P), recall (R), parameters (Params), and speed (FPS). Among them, mAP@0.5 is the average precision (AP) value at a single Intersection over Union (IoU) threshold, which is relatively simple to calculate, while mAP@0.5:0.95 considers multiple IoI thresholds and is the core metric for overall model performance, better reflecting the model's comprehensive strength; higher P and R represent fewer false positives and false negatives, respectively, directly reflecting the reliability of the detection results; the number of parameters reflects the computational complexity of the model; FPS measures the number of images processed per unit time, quantifies the model's inference speed, and is a key indicator for evaluating real-time performance.
[0061] Generalization validation: Select other datasets for generalization testing, such as the FracAtlas dataset, a collection of musculoskeletal radiographs of multiple sites.
[0062] 5) Model testing and deployment: Static image testing: Use the trained model (best.pt) to perform inference tests on single or batch fracture images, visualize the detection results (bounding boxes, categories, confidence scores), and qualitatively analyze the detection performance.
[0063] Edge deployment: Convert the model to a deployment-friendly format (such as TensorRT, ONNX), integrate it into an embedded platform (such as NVIDIA Jetson AGX Orin) or fracture detection device, import real fracture images for real-time fracture diagnosis, and the final detection results are as follows: Figure 7 As shown.
[0064] In summary, this invention constructs a lightweight and structurally adaptive bone fracture detection model, MAG-YOLO, based on the YOLO11n framework, adhering to a two-layer design approach combining geometric optimization and feature enhancement. At the feature enhancement level, this invention introduces a Global Attention Mechanism (GAM) into the YOLO11 Neck. By establishing a global interaction relationship between the channel and spatial dimensions, the network can more accurately focus on the local structural features of the fracture region and its surroundings under complex background conditions, thus addressing the problem of insufficient representation of subtle crack features in existing technologies. At the geometric optimization level, this embodiment uses MorphAware-IoU as the bounding box regression loss function. By introducing morphological consistency constraints and sample quality differentiation mechanisms, it improves the regression stability for slender and irregular bone fracture targets and effectively reduces false detections. This embodiment aims to solve the technical problems of low detection accuracy, unstable training, and high false positive rates in existing fracture detection technologies while ensuring model lightweighting and computational efficiency, achieving high-precision and stable detection of multiple types of bone fracture targets.
[0065] Therefore, the embodiments of the present invention have the following advantages compared with the prior art: 1) Improving the adaptability of bounding box regression to bone fracture morphology from a geometric mechanism perspective. Addressing the problem that existing IoU loss methods, which primarily rely on overlapping area and center distance for uniform constraints and struggle to characterize slender bone fracture morphologies, this embodiment proposes MorphAware-IoU. This introduces gating proportional constraints and direction-aware center distance penalties during the regression process. This allows the regression penalty to adaptively allocate in different directions based on the actual target's morphological proportions, thereby imposing stricter geometric constraints on the short axis of the bone fracture target while maintaining reasonable tolerance on the long axis, effectively improving the localization accuracy of fine, irregular bone fracture targets.
[0066] 2) Improve the stability and reliability of IoU regression optimization through fuzzy compensation and sample quality differentiation mechanisms. Addressing the issue that existing IoU losses tend to over-penalize and cause training oscillations on samples of moderate matching quality and with ambiguous boundaries, this embodiment introduces a fuzzy perception compensation mechanism in MorphAware-IoU to adaptively weaken the morphological penalty term. Combined with a sample quality differentiation mechanism, it adjusts the regression contribution of samples with different matching qualities, making the optimization process smoother and more stable. This technically solves the problem of insufficient stability of existing IoU losses in uncertain sample scenarios.
[0067] 3) By employing a synergistic design of global attention and morphological perception regression, the overall detection accuracy is improved and the false positive rate is reduced. This embodiment introduces a global attention mechanism (GAM) in the feature fusion stage to enhance the global consistency and discriminativeness of crack-related features in multi-scale space. Furthermore, MorphAware-IoU is used to transform these feature advantages into stable geometric regression results that conform to the structural characteristics of bone cracks. This creates a synergistic closed loop between feature enhancement and regression optimization, thereby significantly improving detection accuracy and effectively suppressing false positives in complex skeletal backgrounds.
[0068] 4) Achieving improved stability while maintaining a lightweight model, resulting in strong engineering applicability. This embodiment is an improvement on a lightweight single-stage detection framework. GAM is only applied to key nodes of feature fusion, and MorphAware-IoU as a regression loss is only introduced during the training phase without increasing computational overhead during the inference phase. Therefore, it achieves simultaneous improvement in performance and stability without significantly increasing the number of model parameters and computational complexity, making it suitable for resource-constrained clinical terminals and practical fracture detection applications.
[0069] Reference Figure 2 A fracture detection system based on an improved loss function and lightweight attention includes: The first module 201 is used to acquire fracture image datasets and perform data preprocessing to construct preprocessed fracture image datasets. The second module 202 is used to introduce a global attention mechanism and a bounding box regression loss function to build a fracture detection model; The third module 203 is used to detect fractures in the preprocessed fracture image dataset based on the fracture detection model to obtain fracture detection results.
[0070] The content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0071] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.
Claims
1. A fracture detection method based on an improved loss function and lightweight attention, characterized in that, Includes the following steps: Acquire fracture image datasets and perform data preprocessing to construct preprocessed fracture image datasets; A fracture detection model is constructed by introducing a global attention mechanism and a bounding box regression loss function; The fracture detection model is used to detect fractures in the preprocessed fracture image dataset to obtain fracture detection results.
2. The fracture detection method based on improved loss function and lightweight attention according to claim 1, characterized in that, The fracture detection model specifically includes a backbone network, a neck network, and a detection head, wherein: The backbone network includes a first convolutional module, a first C3k2 module, a spatial pyramid pooling module, and a partial spatial attention module. The first convolutional module includes a first convolutional layer, a second convolutional layer, a third convolutional layer, a fourth convolutional layer, and a fifth convolutional layer. The first C3k2 module includes a first C3k2 block, a second C3k2 block, a third C3k2 block, and a fourth C3k2 block. The neck network includes a feature concatenation module, a second C3k2 module, a feature upsampling module, a global attention mechanism module, and a second convolution module. The feature upsampling module includes a first feature upsampling layer and a second feature upsampling layer. The feature concatenation module includes a first feature concatenation layer, a second feature concatenation layer, a third feature concatenation layer, and a fourth feature concatenation layer. The second C3k2 module includes a fifth C3k2 block, a sixth C3k2 block, a seventh C3k2 block, and an eighth C3k2 block. The global attention mechanism module includes a first global attention layer, a second global attention layer, and a third global attention layer. The second convolution module includes a sixth convolution layer and a seventh convolution layer. The detection head includes a first detection head, a second detection head, and a third detection head.
3. The fracture detection method based on improved loss function and lightweight attention according to claim 2, characterized in that, The backbone network, the neck network, and the detection head are connected in sequence, wherein: In the backbone network, the first convolutional layer, the second convolutional layer, the first C3k2 block, the third convolutional layer, the second C3k2 block, the fourth convolutional layer, the third C3k2 block, the fifth convolutional layer, the fourth C3k2 block, the spatial pyramid pooling module, and the partial spatial attention module are connected in sequence. In the neck network, the first feature upsampling layer, the first feature splicing layer, the fifth C3k2 block, the second feature upsampling layer, the second feature splicing layer, the sixth C3k2 block, the first global attention layer, the sixth convolutional layer, the third feature splicing layer, the seventh C3k2 block, the second global attention layer, the seventh convolutional layer, the fourth feature splicing layer, the eighth C3k2 block, and the third global attention layer are connected in sequence; The output of the second C3k2 block is connected to the input of the second feature stitching layer, the output of the third C3k2 block is connected to the input of the first feature stitching layer, the output of the partial spatial attention module is connected to the input of the first feature upsampling layer and the input of the fourth feature stitching layer, the output of the sixth C3k2 block is connected to the input of the third feature stitching layer, the output of the first global attention layer is connected to the input of the first detection head, the output of the second global attention layer is connected to the input of the second detection head, and the output of the third global attention layer is connected to the input of the third detection head.
4. The fracture detection method based on improved loss function and lightweight attention according to claim 3, characterized in that, The bounding box regression loss function serves as the localization loss function of the fracture detection model, measuring the geometric consistency between the predicted bounding box output by the detection head and the true bounding box in terms of position, scale, and shape. The bounding box regression loss function includes gating proportional constraints, fuzzy perception compensation, and sample quality discrimination, wherein: The gating scaling constraint includes a scaling constraint term and a distance weighting term. The gating scaling constraint is used to constrain the shape consistency between the predicted bounding box and the ground truth bounding box at the geometric level, where the expression is: ; ; In the above formula, Indicates the proportional constraint term. This represents the distance-weighted term. This represents the aspect ratio of the longer side to the wider side of the actual bounding box. , These represent the weighting coefficients for the horizontal and vertical directions, respectively. This represents the diagonal distance between the smallest bounding box and the predicted box. This represents the gated term calculated using the sigmoid function. This represents the morphological difference term after normalization. Indicates the geometric center coordinates of the prediction box. Represents the geometric center coordinates of the true bounding box; The fuzzy perception compensation is used to adaptively reduce the morphological penalty of samples with moderate matching quality, and its expression is: ; ; In the above formula, Indicates the proportional constraint term. This represents the distance-weighted term. This represents the morphological penalty term after compensation. This represents the global adjustment weight of the proportional constraint term. Indicates intersection, union, and ratio. This represents the comprehensive geometric penalty term used in the above geometric error calculation. Indicates the basic loss item; The sample quality differentiation is used to integrate overlap quality and morphological consistency information to assign differentiated regression weights to different samples. The expression for this weighting is: ; In the above formula, This represents the sample quality discrimination loss function. This represents the basic weights that distinguish high-quality samples. This represents the basic loss item.
5. The fracture detection method based on improved loss function and lightweight attention according to claim 4, characterized in that, The step of detecting fractures in the preprocessed fracture image dataset based on the fracture detection model to obtain fracture detection results specifically includes: The preprocessed fracture image dataset is input into the fracture detection model; Based on the backbone network of the fracture detection model, feature extraction processing is performed on the preprocessed fracture image dataset to obtain multi-scale fracture image features. Based on the neck network of the fracture detection model, feature fusion processing is performed on the multi-scale fracture image features to obtain the fused multi-scale fracture image features. The detection head based on the fracture detection model performs fracture feature detection on the fused multi-scale fracture image features to obtain fracture detection results.
6. The fracture detection method based on improved loss function and lightweight attention according to claim 5, characterized in that, The backbone network based on the fracture detection model performs feature extraction processing on the preprocessed fracture image dataset to obtain multi-scale fracture image features. This step specifically includes: The preprocessed fracture image dataset is input into the backbone network of the fracture detection model; Based on the first convolutional module of the backbone network, edge texture information and high-level semantic information are extracted from the preprocessed fracture image dataset to obtain multi-scale feature maps. Based on the first C3k2 module of the backbone network, the multi-scale feature map is segmented and the information flow is optimized to obtain a multi-scale resolution feature map. Based on the spatial pyramid pooling module of the backbone network, the receptive field feature is enlarged to obtain the expanded multi-scale resolution feature map. Based on the partial spatial attention module of the backbone network, the weights of the expanded multi-scale resolution feature map are adaptively adjusted to obtain multi-scale fracture image features.
7. The fracture detection method based on an improved loss function and lightweight attention as described in claim 6, characterized in that, The step of the neck network based on the fracture detection model performing feature fusion processing on multi-scale fracture image features to obtain fused multi-scale fracture image features specifically includes: Multiscale fracture image features are input into the neck network of the fracture detection model; Based on the feature upsampling module of the neck network, the multi-scale fracture image features are upsampled to obtain the upsampled multi-scale fracture image features. Based on the feature stitching module of the neck network, feature stitching processing is performed on the upsampled multi-scale fracture image features to obtain the stitched multi-scale fracture image features. Based on the second C3k2 module of the neck network, the spliced multi-scale fracture image features are optimized to obtain optimized multi-scale fracture image features. The global attention mechanism module and the second convolution module based on the neck network are used to perform weighted adjustment and fusion of the complementary relationship between fine-grained location information and high-level semantic information on the optimized multi-scale fracture image features, so as to obtain the fused multi-scale fracture image features.
8. A fracture detection system based on an improved loss function and lightweight attention, characterized in that, Includes the following modules: The first module is used to acquire fracture image datasets and perform data preprocessing to construct preprocessed fracture image datasets. The second module is used to introduce a global attention mechanism and a bounding box regression loss function to build a fracture detection model. The third module is used to detect fractures in the preprocessed fracture image dataset based on the fracture detection model, and obtain fracture detection results.