Spaces:
Sleeping
Sleeping
| license: apache-2.0 | |
| title: tree_canopy | |
| sdk: docker | |
| emoji: π» | |
| colorFrom: blue | |
| colorTo: yellow | |
| short_description: tree segmentation | |
| # π³ Tree Segmentation from Aerial Imagery (Solafune Platform) | |
| ## π Overview | |
| This project focuses on segmenting **individual trees** and **groups of trees** from high-resolution aerial imagery. | |
| The dataset comes from the **Solafune** platform and includes two segmentation targets: | |
| - **`individual_tree`** | |
| - **`group_of_trees`** | |
| Each image is **1204 Γ 1204 pixels**, captured at ground resolutions ranging from **20 cm to 80 cm** per pixel. | |
| This means one pixel corresponds to **0.2 m to 0.8 m** of ground area. | |
| A key challenge in this dataset is the **extremely high object density**: | |
| β‘οΈ **~4000 tree instances per image**, requiring robust segmentation techniques and efficient processing strategies. | |
| --- | |
| ## π± Problem Description | |
| Given aerial RGB images, the task is to **segment tree regions** into: | |
| - Individual trees | |
| - Groups of trees | |
| Challenges include: | |
| - Very high object density | |
| - Varying tree scales | |
| - Large variation in resolution (20 cm to 80 cm) | |
| - Shadows, illumination differences | |
| - Large image size (1204Γ1204) | |
| --- | |
| ## π§ͺ Approaches Implemented | |
| Two separate solutions were developed: | |
| 1. **YOLO11-Seg (with SAHI slicing)** | |
| 2. **Mask2Former (with Swin-Tiny backbone + SAHI)** | |
| Both solutions use **SAHI** (Slicing Aided Hyper Inference) to efficiently handle large images and to improve small-object performance. | |
| --- | |
| # π· 1. Mask2Former Implementation | |
| ## π Model Details | |
| - **Backbone:** Swin Transformer Tiny | |
| - **Architecture:** Mask2Former (query-based segmentation) | |
| - **Pretraining:** COCO-Segments | |
| - **Training Resolution:** **480 Γ 480** (sliced) | |
| - **Why sliced training?** | |
| - Full 1204Γ1204 images have ~4000 tree instances | |
| - Mask2Former uses **query-based detection**, where: | |
| - **#queries β #objects** | |
| - Using thousands of queries significantly slows down cross-attention | |
| - Training on smaller slices reduces both: | |
| - Compute cost | |
| - GPU memory usage | |
| - Attention complexity | |
| ## π Data Augmentations | |
| Standard Albumentations: | |
| - Horizontal / vertical flip | |
| - Random rotate | |
| - Color jitter | |
| - Gaussian noise | |
| Custom augmentations: | |
| - **Synthetic shadows** added to mimic aerial lighting variations | |
| - **Noise injection** for `individual_tree` class (high sample count) | |
| - Avoids oversampling imbalance | |
| - Preserves dataset richness | |
| ## π Performance | |
| | Metric | Score | | |
| |--------|--------| | |
| | **mAP@75** | **0.40** | | |
| Mask2Former performs significantly better because of its strong global reasoning and segmentation-focused architecture. | |
| --- | |
| # π· 2. YOLO11-Seg Implementation | |
| ## π Model Details | |
| - **Model:** YOLO11x-Seg | |
| - **Image Handling:** SAHI slicing | |
| - **Reason:** | |
| - YOLO struggles with extremely dense small objects on large images | |
| - Memory constraints prevent full-resolution training on 1204Γ1204 | |
| - SAHI allows per-slice detection, making training feasible | |
| ## π Performance | |
| | Metric | Score | | |
| |--------|--------| | |
| | **mAP@75** | **0.11** | | |
| YOLO11 underperforms in this scenario because: | |
| - Dense small objects are harder for YOLO | |
| - Segmentation masks become noisy in crowded environments | |
| - Attention-free architecture limits instance separation | |
| --- | |
| # π§ Key Insights | |
| - **High-density segmentation (>4000 objects)** requires query-based or transformer-style models. | |
| - **Mask2Former** handles dense tree structures far better than YOLO. | |
| - **SAHI** is essential for both training and inference: | |
| - Reduces GPU memory load | |
| - Improves small-object detection | |
| - Accelerates training on large images | |
| - Custom shadow and noise augmentations helped improve model robustness. | |
| - Lower-resolution images (20-80 cm) require scale-robust architectures. | |
| --- | |
| # π Results Summary | |
| | Model | Backbone | mAP@75 | Notes | | |
| |-------|----------|--------|-------| | |
| | **Mask2Former** | Swin-Tiny | **0.40** | Best performer, strong with dense segments | | |
| | **YOLO11x-Seg** | CSP-based | **0.11** | Struggles with extremely dense small objects | | |
| --- | |
| # π Future Improvements | |
| - Use **Swin-Large** or **Swin-Base** for deeper feature representation | |
| - Train Mask2Former with **larger query capacity** | |
| - Add **class-specific weighting** to handle imbalance between `individual_tree` and `group_of_trees` |