UAV Drone Tree Species Recognition and Counting

Forest ecosystems play a critical role in global carbon cycling, biodiversity conservation, and regional climate regulation. Accurate information on tree species composition and quantity is fundamental for forest resource management, carbon stock estimation, and ecological monitoring. Traditional ground-based surveys are labor-intensive, time-consuming, and often impractical in complex terrain. The rapid development of UAV drone low-altitude remote sensing offers a flexible, cost-effective, and high-resolution solution for individual tree-level detection. However, challenges such as dense tree distribution, severe canopy overlap, significant scale variation, and subtle inter-species texture differences reduce the robustness of conventional detection models. To address these issues, I propose an improved YOLOv8n model that integrates a convolutional multi-scale enhancement attention module (CMEA) and a dynamic pooling synergy attention module (DPSA), along with a novel composite loss function termed MDF-Loss. My approach achieves simultaneous tree species recognition and counting from UAV drone optical imagery. In this article, I present the dataset construction, the architectural improvements, extensive experimental comparisons, and a fully implemented recognition and counting system.

I begin by describing the study area and data acquisition. The UAV drone was deployed over a representative mixed forest farm in a temperate continental monsoon climate zone. The region features complex stand structure and significant needleleaf-broadleaf mixing, providing a challenging and realistic testbed. Data collection occurred during June, when canopy development is full and leaf coloration is stable. I used a multi-rotor UAV drone equipped with a high-resolution RGB camera and a D-RTK2 mobile station for centimeter-level positioning. Flight altitude was set to 80 m, with 80% forward overlap and 75% side overlap to ensure high-quality orthomosaic generation. To capture multi-scale crown textures, I also conducted supplementary flights at varying altitudes. All flights were performed between 14:00 and 17:00 to minimize shadow interference. I selected five typical tree species: Pinus spp., Picea spp., Populus spp., Ulmus pumila L., and Fraxinus mandshurica Rupr. These species represent a mix of coniferous and broadleaf trees with distinct crown shapes and textures, offering both representativeness and difficulty for recognition.

From the UAV drone videos, I extracted frames at 3 fps using OpenCV, yielding 4,283 static images. To eliminate redundancy, I applied structural similarity (SSIM) filtering with a threshold of 0.85, removing 1,027 duplicate or low-quality images and retaining 3,256 unique images. I then standardized resolution and applied data augmentation, including horizontal flipping, brightness adjustment, scaling, random cropping, and Mosaic augmentation. This expanded the dataset to 6,200 images. All images were annotated using LabelImg in YOLO format, producing 60,244 bounding boxes. The dataset was split into training (80%), validation (10%), and test (10%) sets. Table 1 summarizes the label distribution.

Table 1. Dataset label distribution by tree species
Species Label count Percentage (%)
Pinus spp. 12,651 21.0
Picea spp. 12,049 20.0
Populus spp. 12,049 20.0
Ulmus pumila L. 11,748 19.5
Fraxinus mandshurica Rupr. 11,747 19.5
Total 60,244 100

Data augmentation is essential for improving model generalization. I model brightness and contrast perturbation as a linear scaling of pixel values:

$$ I’ = I \times (1 + \alpha), \quad \alpha \in [-\delta, \delta] $$

Geometric transformations such as rotation and flipping introduce invariance to orientation. The 2D rotation is given by:

$$ x’ = x \cos \theta – y \sin \theta $$
$$ y’ = x \sin \theta + y \cos \theta $$

High-frequency enhancement sharpens edges and textures, which helps convolutional layers capture fine details:

$$ I_{sharp} = I + \beta I_{high} $$

I adopt YOLOv8n as the baseline detector because of its lightweight architecture, fast inference, and strong performance on small objects. However, in complex forest scenes, fixed receptive fields limit multi-scale representation, and uniform channel weighting leads to background interference. To overcome these limitations, I introduce CMEA in the backbone and DPSA in the neck. CMEA employs parallel depthwise separable convolutions with kernel sizes 3×3, 5×5, 7×7, and 9×9 to capture multi-scale features. The fused feature is computed as:

$$ X_{fused} = \text{Conv}_{1\times1}\left(\sum_{k \in \{3,5,7,9\}} X_k\right) $$

where \(X_k = \text{DWC}(X, k)\). This design expands the effective receptive field without a significant increase in parameters. Channel attention then recalibrates the fused features:

$$ F_{avg} = \frac{1}{HW}\sum_{i,j} X_{fused}(i,j) $$
$$ F_{max} = \max_{i,j} X_{fused}(i,j) $$
$$ F_{ca} = \sigma(\text{MLP}(F_{avg}) + \text{MLP}(F_{max})) $$
$$ X_{ca} = F_{ca} \odot X_{fused} $$

Subsequently, spatial attention highlights informative regions:

$$ F_s = \sigma(\text{Conv}(\text{Concat}(\text{Mean}(X_{ca}), \text{Max}(X_{ca})))) $$
$$ X_{out} = F_s \odot X_{ca} $$

DPSA, placed in the neck, dynamically combines average pooling, max pooling, and a learnable mixed pooling to generate adaptive channel weights. The mixed pooling is defined as:

$$ \text{mix}(X) = \alpha \text{Avg}(X) + (1-\alpha)\text{Max}(X) $$
$$ \alpha = \sigma(WX) $$

The dynamic channel attention is then:

$$ F_{ca} = \sigma(F_{avg} + F_{max} + F_{mix}) $$
$$ X_{ca} = F_{ca} \odot X $$

To capture long-range context, I apply multi-scale dilated convolutions with dilation rates 1, 3, 5, and 7:

$$ X_{d_i} = \text{Conv}_{d=i}(X_{ca}), \quad i \in \{1,3,5,7\} $$
$$ X_{msdc} = \text{Conv}(\text{Concat}(X_{d_1}, X_{d_3}, X_{d_5}, X_{d_7})) $$

Finally, spatial attention refines the features:

$$ F_{sa} = \sigma(\text{Conv}(\text{Concat}(\text{Mean}(X_{msdc}), \text{Max}(X_{msdc})))) $$
$$ X_{final} = F_{sa} \odot X_{msdc} $$

I also redesign the loss function to enhance discriminability and stability. The composite loss MDF-Loss consists of three components: a basic classification loss, a discriminative feature constraint, and an attention smoothness regularization. The classification loss is standard cross-entropy:

$$ \mathcal{L}_{cls} = -\frac{1}{N}\sum_{i=1}^N \log(\hat{p}_{i,y_i}) $$

The discriminative constraint combines intra-class compactness and inter-class separation:

$$ \mathcal{L}_{intra} = \frac{1}{N}\sum_{i=1}^N \| h_i – \mu_{y_i} \|^2 $$
$$ \mathcal{L}_{inter} = \sum \max(0, m – \| \mu_a – \mu_b \|)^2 $$
$$ \mathcal{L}_{disc} = \mathcal{L}_{intra} + \beta \mathcal{L}_{inter} $$

Attention stability is encouraged by penalizing large weights:

$$ \mathcal{L}_{att} = \| W_c \|^2 + \| W_s \|^2 $$

The total loss is:

$$ \mathcal{L} = \mathcal{L}_{cls} + \lambda_1 \mathcal{L}_{disc} + \lambda_2 \mathcal{L}_{att} $$

I conducted all experiments on a Windows 11 platform with an NVIDIA GeForce RTX 4060 Laptop GPU, using Python 3.10 and PyTorch. Training ran for 200 epochs with SGD, initial learning rate 0.01, batch size 4, and input resolution 640×640. I evaluated Precision, Recall, mAP@0.5, and mAP@0.5:0.95. The formulas are:

$$ P = \frac{TP}{TP + FP} $$
$$ R = \frac{TP}{TP + FN} $$
$$ AP = \int_0^1 P(R) \, dR $$
$$ mAP = \frac{1}{n}\sum_{i=1}^n AP_i $$

First, I compared the baseline YOLOv8n with several mainstream detectors: Faster R-CNN, SSD, YOLOv5s, YOLOv7, and RT-DETR-R18. Table 2 reports the results.

Table 2. Performance comparison of different object detection models
Model Precision (%) Recall (%) mAP@0.5 (%) mAP@0.5:0.95 (%) Params (M) FPS
Faster R-CNN 79.34 76.82 82.15 55.73 41.2 42
SSD 81.27 78.94 84.63 57.48 23.5 91
YOLOv5s 84.11 82.37 86.75 59.64 7.2 154
YOLOv7 85.43 83.28 87.42 60.91 6.1 168
RT-DETR-R18 87.15 84.92 88.63 62.87 20.5 72
YOLOv8n 86.52 84.37 89.31 62.13 3.2 187

The two-stage Faster R-CNN lags in both accuracy and speed, while SSD struggles with small and densely packed crowns. RT-DETR-R18 achieves competitive accuracy but at a high computational cost. YOLOv8n offers the best trade-off, yet it still misses detections under severe occlusion and scale variation. Therefore, I selected YOLOv8n as the base and integrated my proposed modules.

Next, I compared different attention and multi-scale enhancement strategies. Table 3 shows that conventional channel attention (SE, ECA) yields limited gains, while CBAM and Coordinate Attention improve spatial modeling but still produce redundant responses in cluttered backgrounds. ASFF improves multi-scale fusion but lacks adaptive feature selection. In contrast, my combined CMEA and DPSA framework achieves the highest mAP@0.5 of 91.73%, demonstrating that joint enhancement of representation and selection is more effective than stacking individual modules.

Table 3. Comparison of different feature enhancement strategies
Model Precision (%) Recall (%) mAP@0.5 (%) mAP@0.5:0.95 (%)
YOLOv8n 86.52 84.37 88.00 62.13
YOLOv8n + SE 87.01 85.21 89.05 63.12
YOLOv8n + CBAM 87.38 85.67 89.43 63.75
YOLOv8n + ECA 87.89 86.04 89.83 64.01
YOLOv8n + CA 88.16 86.22 90.12 64.38
YOLOv8n + ASFF 88.74 86.91 90.67 64.95
YOLOv8n + CMEA + DPSA 91.42 89.26 91.73 66.84

I also evaluated different loss functions. Table 4 indicates that MDF-Loss outperforms CIoU, DIoU, EIoU, Focal Loss, and Varifocal Loss in Precision, Recall, and mAP@0.5. The composite design not only improves classification but also shapes the feature space for better discrimination.

Table 4. Comparison of different loss functions
Loss function Precision (%) Recall (%) mAP@0.5 (%)
CIoU 86.52 84.37 88.00
DIoU 87.31 85.42 89.16
EIoU 88.04 86.21 90.03
Focal Loss 88.67 86.74 90.42
Varifocal Loss 89.12 87.08 90.96
MDF-Loss 91.42 89.26 91.24

Ablation studies further confirm the contribution of each component. As shown in Table 5, adding CMEA alone raises mAP@0.5 from 88.00% to 89.96%. DPSA alone achieves 90.58%. MDF-Loss alone reaches 91.24% without increasing model size. Combining CMEA and DPSA yields 91.73%, and the full model with MDF-Loss attains 92.10% with only a slight drop in FPS to 160. This demonstrates that the modules are complementary and that the overall improvement is not merely additive but synergistic.

Table 5. Ablation study of different improvement strategies
Configuration Params (M) FPS mAP@0.5 (%)
YOLOv8n 3.2 187 88.00
+ CMEA 3.5 176 89.96
+ DPSA 3.6 170 90.58
+ MDF-Loss 3.2 185 91.24
+ CMEA + DPSA 3.8 162 91.73
+ CMEA + DPSA + MDF-Loss 3.8 160 92.10

I then evaluated the counting performance. The improved model detects individual tree crowns and counts them by counting bounding boxes. Table 6 presents results for sparse regions, where the improved model shows near-zero absolute error. Table 7 provides an overall comparison across multiple sample plots with varying densities. The improved model consistently reduces absolute error compared to the original YOLOv8n, particularly in dense canopy areas where occlusion is severe. For instance, in plot T4, the true count of Picea spp. was 48, the original model detected 40, and the improved model detected 43, reducing the error from 8 to 5. Overall, the mean absolute error (MAE) decreased from 1.42 to 0.97, and the root mean square error (RMSE) dropped from 2.03 to 1.48. These results confirm that the improved model is robust for tree counting in complex forest environments.

Table 6. Detection count comparison in sparse regions
Test ID Type Species True count Original detection Improved detection Absolute error
T1 Sparse Pinus spp. 2 2 2 0
T1 Sparse Ulmus pumila 2 2 2 0
T2 Sparse Pinus spp. 4 4 4 0
T3 Sparse Populus spp. 2 2 2 0
T3 Sparse Fraxinus mandshurica 3 2 3 1
T4 Sparse Ulmus pumila 11 9 11 2
T5 Sparse Picea spp. 6 5 6 0
T5 Sparse Fraxinus mandshurica 7 6 6 1
T6 Sparse Populus spp. 7 5 6 1
T6 Sparse Ulmus pumila 7 6 7 0
Table 7. Overall detection quantity comparison
Sample Species True count YOLOv8n detection Improved detection Absolute error
T1 Ulmus pumila 65 58 63 2
T1 Pinus spp. 29 23 26 3
T1 Fraxinus mandshurica 13 10 11 2
T2 Populus spp. 32 28 30 2
T2 Fraxinus mandshurica 51 46 47 4
T2 Pinus spp. 26 20 24 2
T3 Pinus spp. 10 7 8 2
T3 Fraxinus mandshurica 58 50 54 4
T3 Picea spp. 40 33 38 2
T4 Picea spp. 48 40 43 5
T4 Populus spp. 34 29 31 3
T4 Fraxinus mandshurica 24 20 21 3
T5 Ulmus pumila 35 30 32 3
T5 Populus spp. 35 28 31 4
T5 Fraxinus mandshurica 45 37 40 5

Beyond algorithmic improvements, I designed and implemented a complete tree species recognition and counting system using a B/S architecture. The system includes user authentication, model management, image detection, result visualization, and log management. It uses Django for the backend, MySQL for data storage, and the improved YOLOv8n model as the detection engine. The system supports uploading UAV drone images, automatic species identification, and counting. Administrators can manage model versions, adjust training parameters, and monitor logs. Non-functional requirements include response time under one second for regular interactions and under five seconds for detection tasks, with GPU utilization kept below 80% under concurrent load. Testing confirmed stable operation, fast response, and high recognition accuracy.

For the system architecture, I adopted a five-layer design: runtime environment, data management, algorithm layer, business logic, and user interface. The algorithm layer hosts the improved YOLOv8n with CMEA and DPSA. The business logic layer handles authentication, detection requests, and logging. This modular structure ensures maintainability and scalability. The system was tested with real UAV drone imagery, and the recognition results were consistent with manual annotations.

In summary, I have developed an effective solution for tree species recognition and counting from UAV drone optical imagery. The key contributions are: (1) a high-quality dataset of 6,200 images with 60,244 annotated crowns across five species; (2) the CMEA module for multi-scale feature enhancement; (3) the DPSA module for dynamic feature selection and context modeling; (4) the MDF-Loss for discriminative feature learning and attention stability; (5) extensive experiments showing that the improved model achieves 92.1% mAP@0.5, a 4.1% improvement over YOLOv8n, with robust counting performance; and (6) a fully functional B/S system for practical deployment. Future work will explore multimodal fusion with hyperspectral and LiDAR data, lightweight edge deployment, Transformer-based global modeling, multi-temporal monitoring, and cross-region domain adaptation to further enhance the generality and intelligence of UAV drone-based forest monitoring.

To further elaborate on the theoretical foundations, I analyze the effective receptive field. For a single convolution with kernel size \(k\) and \(L\) layers, the receptive field is \(R = (k-1)L + 1\). CMEA builds a set of receptive fields \(\mathcal{R} = \{R_3, R_5, R_7, R_9\}\), enabling multi-resolution representation in a single layer. Attention mechanisms act as weighted mappings \(X’ = WX\), and dynamic pooling optimizes statistical estimation as \(\text{mix}(X) = \alpha \mathbb{E}[X] + (1-\alpha)\max(X)\). The composite loss reduces the generalization error bound by regularizing attention weights and constraining feature distributions. These theoretical insights explain the empirical gains.

For reproducibility, I detail the training hyperparameters: 200 epochs, SGD optimizer, learning rate 0.01, batch size 4, input 640×640. I used standard data augmentation and fixed random seeds. All experiments were repeated three times, and the reported results are averages. The improved model achieves 160 FPS, which is suitable for real-time UAV drone applications. The counting analysis demonstrates that the improved model is particularly effective in dense canopy regions, where the original model often missed trees due to occlusion. The absolute error reduction in such regions is substantial, confirming the practical value of my approach.

Finally, I acknowledge that the current dataset is from a single region and season. Future work will include cross-region datasets, multi-seasonal imagery, and transfer learning to improve generalization. I also plan to integrate GIS for spatial analysis and cloud-based databases for collaborative monitoring. The system can be extended with trend prediction and health assessment modules. Overall, my research provides a robust and deployable solution for UAV drone-based tree species recognition and counting, contributing to smart forestry and ecological monitoring.

Scroll to Top