code for "Detection and Geographic Localization of Natural Objects in the Wild: A Case Study on Palms"
- [2025-04-28] 🎉 Our paper, "Detection and Geographic Localization of Natural Objects in the Wild: A Case Study on Palms," has been accepted by IJCAI 2025! We are thrilled to share our work with the community. 🥳
This repository contains a comprehensive system for palm tree detection, segmentation, and analysis using UAV imagery. The codebase provides tools for processing orthomosaic images, training object detection models, and analyzing detection results for palm tree counting and monitoring.
- Full Dataset Download: PALMS
Palm_detection_code/ # Main code directory
├── Train/ # Model training scripts
│ ├── train_ultra.py # Training using Ultralytics framework (YOLO, RTDETR)
│ └── train_mmdet.py # Training using MMDetection framework (DINO)
├── SAM/ # Segment Anything Model implementation
│ ├── Orthomosaic/ # Scripts for processing large orthomosaic images
│ │ ├── 1-predict.py # Detection on orthomosaic using sliding window
│ │ ├── 2-nms.py # Non-maximum suppression for overlapping detections
│ │ └── 3-segment.py # Segmentation of detected palms
│ └── Raw_data/ # Processing for raw imagery
├── Calibration/ # Model calibration tools
│ ├── calibration_models/ # Temperature scaling and other calibration methods
│ └── generate_json_files/ # Prepare data for calibration
├── tools/ # Utility tools for the project
│ ├── counting/ # Palm counting tools from detection results
│ ├── saliency_map/ # Visualization of model attention
│ ├── eval/ # Evaluation scripts for model performance
│ ├── generate_yolo_tarin_data/ # Data preparation for YOLO/RTDETR
│ └── generate_mmdet_train_data/ # Data preparation for MMDetection models
└── requirements.txt # Python dependencies
Data_example/ # Example dataset structure
├── images/ # Example training images
├── labels/ # Corresponding annotations in YOLO format
└── ReadMe.txt # Note about data availability
The project depends on the following main packages:
torch==2.0.1
torchvision==0.15.2
ultralytics==8.3.38
mmcv==2.2.0
mmengine==0.10.6
opencv_python==4.9.0.80
rasterio==1.4.3
Pillow==11.1.0
numpy==1.24.1
pandas==2.2.3
Shapely==2.0.7
PyYAML==6.0.2
tqdm==4.66.4
git clone <repository-url>
cd Palm_detection_code
pip install -r requirements.txtcd Palm_detection_code/Train
python train_ultra.pycd Palm_detection_code/Train
python train_mmdet.pyThe system uses a sliding window approach to process large orthomosaic images and detect palm trees:
- Run detection on image tiles:
cd Palm_detection_code/SAM/Orthomosaic
python 1-predict.py- Apply Non-Maximum Suppression (NMS) to remove duplicate detections:
python 2-nms.py- Segment detected palm trees:
python 3-segment.pyThe repository provides tools for generating training data in both YOLO/RTDETR and MMDetection formats:
cd Palm_detection_code/tools/generate_yolo_tarin_data
# or
cd Palm_detection_code/tools/generate_mmdet_train_dataEvaluate model performance using the evaluation scripts:
cd Palm_detection_code/tools/eval/ultra
# or
cd Palm_detection_code/tools/eval/mmdetThe repository includes a small example dataset in the Data_example directory. The full dataset will be made available upon publication acceptance.
Dataset format:
- Images: PNG files in
Data_example/images/ - Labels: YOLO format annotations in
Data_example/labels/(class_id, normalized_center_x, normalized_center_y, normalized_width, normalized_height)
The system supports multiple object detection models:
- RTDETR (Real-Time Detection Transformer) from Ultralytics
- YOLOv8/YOLOv11 from Ultralytics
- DINO&DDQ from MMDetection
Contributions to improve the codebase are welcome. Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request