# Log Volume Measurement and Counting Based on Improved Cascade Mask R-CNN and Deep SORT
## 4 Results
### Analysis of Segmentation Results  
To evaluate the effectiveness of integrating the attention mechanism between the feature extraction network and the Feature Pyramid Network (FPN), we conducted a comparative analysis of two baseline algorithms for instance segmentation: Mask R-CNN and Cascade Mask R-CNN. The results of this experimental analysis are presented in Table 2. In the Mask R-CNN algorithm, when utilizing ResNet-CBAM-FPN as the backbone network, the metrics for \(AP\), \(AP_{s}\), \(AP_{m}\), and \(AP_{l}\) were improved by 0.8, 0.2, 0.4, and 0.8, respectively, compared to the scenario without the addition of the attention mechanism. Similarly, in the Cascade Mask R-CNN algorithm, the evaluation metrics saw enhancements of 0.9, 1.4, 1.1, and 1.0, respectively, after integrating the attention mechanism. To further demonstrate the efficacy of the CBAM attention mechanism, we substituted the backbone network of the Cascade Mask R-CNN with RetinaNet-FPN. RetinaNet [37] is a one-stage detection network proposed in 2018. The \(AP\), \(AP_{s}\), \(AP_{m}\), and \(AP_{l}\) metrics still improved by 1.1, 1.2, 0.7, and 1.2, respectively, when using the RetinaNet-FPN backbone network with the attention mechanism. This indicates that incorporating the attention mechanism between the feature extraction network and the feature pyramid network can effectively enhance the ability of the backbone network to extract features and significantly improve the model's segmentation performance. To further validate the performance of the models in detecting log ends, we used Cascade Mask R-CNN as the baseline model for comparison. We conducted a count of the detected log ends by different models, separately tallying the number of true and missed detections. The results are presented in Table 3. The statistical results demonstrate that the inclusion of the CBAM attention mechanism in the backbone network significantly enhances the model's capability to detect log ends, achieving a true detection rate of 98.6%. Additionally, as shown in Figure 6, comparing the results of different backbone network detections reveals a significant under-detection of log ends in images without an attention mechanism. This under-detection is notably improved when using the backbone network with the attention mechanism. However, we also observed that the model fails to detect log ends when stickers or other items obscure the logs. This issue arises because there are no training samples that represent such scenarios in our training dataset, leading to this leakage. To gain deeper insights into the decision-making process of deep convolutional neural networks in object detection, we employed the Grad-CAM++ technique [38] to visualize \begin{table}
\begin{tabular}{l l l l l l} \hline \hline
**Algorithm** & **Backbone** & \(AP\) & \(AP_{s}\) & \(AP_{m}\) & \(AP_{l}\) & \(IOU_{mask}\) \\ \hline Mask R-CNN & ResNet-FPN & 80.5 & 71.6 & 68.3 & 84.8 & 0.950 \\ Mask R-CNN & ResNet-CBAM-FPN & 81.3 & 71.8 & 68.7 & 85.6 & 0.952 \\ Cascade Mask R-CNN & RetinaNet-FPN & 80.9 & 73.7 & 68.1 & 85.0 & 0.953 \\ Cascade Mask R-CNN & RetinaNet-CBAM-FPN & 82.0 & 74.9 & 68.8 & 86.2 & 0.956 \\ Cascade Mask R-CNN & ResNet-FPN & 81.1 & 73.9 & 68.8 & 85.2 & 0.953 \\ Cascade Mask R-CNN & ResNet-CBAM-FPN & **82.3** & **75.3** & **70.9** & **86.2** & **0.958** \\ \hline \end{tabular} Bold values represent the highest performance for each metric.  
\end{table} 
Table 2: Comparison of segmentation effectiveness for different models with CBAM. Figure 6: Log end images detected using different backbone networks. These images were taken in the field at customs ports. The algorithm uses Cascade Mask R-CNN. the model's attention toward the objects. Grad-CAM++ enhances the traditional Grad-CAM method [39] by incorporating higher-order gradient information, allowing for a more accurate and clearer heatmap of object localization. Figure 7 displays the attention heatmap generated using Grad-CAM++.