Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maize Plant Detection in Drone Orthomosaics

Instance segmentation pipeline for detecting young maize plants in large UAV GeoTIFF orthomosaics and estimating crop rows, within-row distances, and candidate planting gaps.

This is a research prototype. The orthomosaic has no plant-level ground truth, so map-wide counts and planting gaps are model estimates rather than field-validated measurements.

Results at a glance

Model Test mask precision Test mask recall Test mask F1 Test mask mAP50 Test mask mAP50–95
YOLOv8s-seg 0.869 0.770 0.817 0.758 0.287
  • 7,185 estimated maize plants after global non-maximum suppression on the selected 30 May orthomosaic
  • 640 × 640 px tiled inference with 25% overlap
  • Fixed, band-wise percentile normalization for consistent contrast across tiles
  • Crop-row assignment and candidate-gap detection in approximate physical units

The confidence threshold is 0.20. It was selected on the validation set with a minimum precision requirement of 80%, prioritizing recall because missed plants can create false candidate gaps.

Example outputs

Tiled instance-segmentation predictions

Example segmentation predictions on the 30 May GeoTIFF

Estimated crop rows and candidate gaps

Colors identify estimated row segments. Red connections indicate consecutive plant centers more than 50 cm apart.

Estimated maize rows and candidate gaps

Pipeline

  1. Combine the separate red, green, and blue bands into RGB images.
  2. Select maize instances from the semantic and instance masks.
  3. Convert each maize mask to a YOLO segmentation polygon.
  4. Preserve the official spatial train/validation/test split (104 / 26 / 26 images).
  5. Normalize the orthomosaic once with fixed per-band 2nd–98th percentile bounds.
  6. Run overlapping tiled inference and map detections back to global pixel coordinates.
  7. Remove duplicate detections from overlapping tiles with global NMS.
  8. Estimate row direction, assign plant centers to row segments, and flag candidate gaps.

For each RGB band, the normalization is:

$$ I_{8\mathrm{bit}} = 255 \cdot \mathrm{clip}\left(\frac{I-p_2}{p_{98}-p_2},\ 0,\ 1\right) $$

The plain \mathrm{clip} notation is used because GitHub's math renderer does not allow the \operatorname macro.

Dataset

This project uses WeedsGalore, a multispectral and multitemporal UAV dataset containing RGB, red-edge, near-infrared, semantic-mask, and instance-mask data from maize fields.

The 2023-05-30_om.tif orthomosaic was selected because individual young maize plants are more visible and weed cover is lower than in the 15 June capture. The paper reports an approximate ground sampling distance of 2.5 mm/px (0.25 cm/px), which is used for approximate distance conversion:

$$ d_{\mathrm{cm}} = d_{\mathrm{px}} \times 0.25 $$

The dataset and orthomosaics are not redistributed in this repository. Follow the upstream project's access and license terms.

Model selection

An initial 10-epoch YOLOv8n-seg run underfit the data. YOLOv8s-seg and YOLO26s-seg were then fine-tuned with the same normalized data, augmentations, imgsz=640, 100-epoch limit, patience=20, and official split. YOLOv8s-seg was selected by validation mask F1.

The final notebook focuses on data preparation and inference. Training runs and model weights are not committed because they are large artifacts. The reported checkpoint is therefore required to reproduce the final inference outputs.

Running locally

Requirements: Python 3.10+ and sufficient RAM/storage for the extracted orthomosaic.

python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
jupyter lab geo_maize_detection.ipynb

Place the downloaded data and trained checkpoint as follows:

geo-maize-detection/
├── data/
│   └── raw/
│       ├── weedsgalore-dataset.zip
│       └── weedsgalore-orthomosaic.zip
├── models/
│   └── yolov8s-seg-best.pt
├── assets/
├── geo_maize_detection.ipynb
└── requirements.txt

The notebook uses CUDA when available, Apple MPS on supported Macs, and otherwise falls back to CPU. Full-orthomosaic inference on CPU can be slow.

Generated CSV and PNG files are written to outputs/, which is intentionally excluded from Git.

Outputs

  • bitki_tahminleri.csv: plant centers, confidence scores, and estimated row IDs
  • bitkiler_arasi_mesafeler.csv: consecutive within-row center distances
  • aday_bosluklar.csv: candidate gaps above 50 cm and at most 200 cm
  • sonuc_ozeti.csv: run summary
  • siralar_ve_aday_bosluklar.png: row and gap visualization
  • geotiff_ornek_segmentasyonlar.png: representative segmentation tiles

Limitations

  • No manual plant-level ground truth exists for the full orthomosaic.
  • Raw training images and the orthomosaic have different appearance distributions.
  • A missed plant can create a false gap; a false positive can hide a real gap.
  • Global NMS can suppress one of two nearby real plants.
  • Distance and row estimates depend on approximate GSD, row direction, and row-spacing assumptions.
  • Results should not be interpreted as agronomic measurements or production-ready recommendations.

Reference

E. Celikkan et al., WeedsGalore: A Multispectral and Multitemporal UAV-Based Dataset for Crop and Weed Segmentation in Agricultural Maize Fields, WACV 2025.

License

Project code is available under the MIT License. Third-party datasets, papers, pretrained components, and model weights remain subject to their respective licenses.

About

Drone GeoTIFF üzerinde genç mısır segmentasyonu, sıra analizi ve aday ekim boşluğu tespiti

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages