# Deep Learning Approach for Arm Fracture Detection Based on an Improved YOLOv8 Algorithm
## 3 Methods
### Modified Model Architecture
#### 3.2.2 Spatial Attention Mechanism  
The Spatial Attention mechanism complements Channel Attention by identifying the most informative spatial regions within the feature maps [38]. This mechanism also starts with average and max pooling operations, which are applied along the channel axis to generate spatial descriptors. The descriptors are concatenated and passed through a convolutional layer, which processes the spatial information. The result is then passed through a sigmoid activation function to generate the spatial attention map. This attention map is multiplied with the input feature maps, highlighting the most important spatial regions and enhancing the network's sensitivity to significant areas within the images. Focusing on relevant spatial locations ensures the model considers the crucial areas for accurate fracture detection.  
The spatial attention mechanism complements channel attention by identifying the most informative spatial regions within the feature maps. This mechanism also startswith average and max pooling operations, but these are applied along the channel axis to generate spatial descriptors, which are given by:  
\[AvgPool(x)=\frac{1}{C}\sum_{k=1}^{C}x_{ijk} \tag{8}\]  
\[MaxPool(x)=x_{ijk} \tag{9}\]  
where \(C\) equals the number of channels in the feature map. \(x_{ijk}\) is the value of the position \((i,j,k)\) in the feature map, where \(k\) indexes over the channels. This operation computes the average value at each spatial location \((i,j)\) across all channels. These descriptors are concatenated via the following equation:  
\[x_{cat}=Concat(AvgPool(x),\ MaxPool(x)) \tag{10}\]  
where \(x_{cat}\) is the concatenated result of the average and max pooled descriptors. _Concat_ combines the average and max pooling results along the channel axis. This concatenates the spatial descriptors to form a combined feature representation. The concatenated descriptors are then passed through a convolutional layer, which processes the spatial information:  
\[f(x)=W*\ x_{cat}+b \tag{11}\]  
where \(W\) is the weight matrix of the convolutional layer and \(b\) is the bias term of the layer. Then, we multiply the weight matrix with the concatenated descriptors. This operation applies a convolutional filter to the concatenated descriptors to extract the spatial attention features. The result is then passed through a sigmoid activation function to generate the spatial attention map:  
\[M_{s}=\sigma(f(x_{cat})) \tag{12}\]  
where \(M_{s}\) is the spatial attention map, \(\sigma\) is the sigmoid activation function that limits the output to a value between 0 and 1, and \(f(x_{cat})\) results from the convolution applied to the concatenated spatial descriptors. This computes the spatial attention map by passing the concatenated spatial descriptors through a convolutional layer followed by a sigmoid activation. This attention map is multiplied by the input feature maps:  
\[x^{\prime\prime}=x^{\prime}*\ M_{s} \tag{13}\]  
where \(x^{\prime\prime}\) is the final output after applying spatial attention, \(x^{\prime}\) is the feature map after applying channel attention, and \(M_{s}\) is the spatial attention map. This final step adjusts the feature map by emphasizing spatial regions using the spatial attention map. Focusing on the relevant spatial locations ensures the model considers the crucial areas for accurate fracture detection.