CSPS_RetinaNet is an improved object detection model based on RetinaNet, specifically designed for detecting rodent burrows in grassland ecosystems using high-resolution satellite imagery. This repository contains the implementation of our novel architecture that integrates CSPDarknet53 backbone with SimAM attention mechanism and GIoU loss for enhanced detection performance.
Haitao Suna, Songbing Zoua*, Zhenqing Jia, Yajie Baia, Wenyong Zhanga, Tenghao Goua, Pengxiang Xiea
a Key Laboratory of Western China's Environmental Systems (Ministry of Education), College of Earth and Environmental Sciences, Lanzhou University, Lanzhou, 730000, China.
*Corresponding author
- CSPDarknet53 Backbone: Efficient feature extraction with cross-stage partial connections
- SimAM Attention Mechanism: Parameter-free spatial attention module for enhanced feature representation
- GIoU Loss: Improved bounding box regression for better localization accuracy
- Feature Pyramid Network (FPN): Multi-scale feature fusion for detecting burrows of various sizes
The CSPS_RetinaNet architecture consists of:
- Backbone Network: CSPDarknet53 for robust feature extraction
- Attention Module: SimAM applied at C3 feature level
- Neck: Feature Pyramid Network (FPN) generating P3-P7 feature levels
- Detection Heads: Separate classification and regression branches
Python >= 3.7
PyTorch >= 1.7.1
CUDA >= 10.2 (for GPU support)pip install -r requirements.txtRequired packages:
- torch
- torchvision
- numpy
- opencv-python
- pillow
- matplotlib
- scipy
- tqdm
- pycocotools
Organize your dataset in VOC format:
VOCdevkit/
└── VOC2007/
├── Annotations/ # XML annotation files
├── JPEGImages/ # Image files
└── ImageSets/
└── Main/
├── train.txt
├── val.txt
└── test.txt
- Prepare your images and annotations in VOC format
- Run the annotation script to generate training files:
python voc_annotation.pyThis will generate 2007_train.txt and 2007_val.txt for training.
Edit model_data/cls_classes.txt to define your class names (one class per line).
Key parameters in train.py:
input_shape: [600, 600] - Input image sizephi: 5 - Use CSPDarknet53 backboneInit_lr: 1e-4 - Initial learning rate (Adam optimizer)Freeze_Epoch: 60 - Epochs for frozen trainingUnFreeze_Epoch: 120 - Total training epochsbatch_size: Adjust based on your GPU memory
-
Prepare your dataset following the VOC format structure
-
Configure training parameters in
train.py:- Set
classes_pathto your classes file - Set
model_pathto pretrained weights (optional) - Adjust
batch_sizebased on GPU memory - Configure training epochs
- Set
-
Start training:
python train.pyThe model will automatically:
- Download pretrained backbone weights
- Perform frozen training (backbone frozen)
- Perform unfrozen training (full model training)
- Save checkpoints in
logs/directory - Generate loss curves and evaluation metrics
For single image prediction:
from retinanet import Retinanet
# Initialize model
model = Retinanet()
# Predict on image
from PIL import Image
image = Image.open('your_image.jpg')
result = model.detect_image(image)
result.show()For batch prediction:
# Set mode to "dir_predict" in predict.py
python predict.pyCalculate mAP on test set:
python get_map.pyThis will generate:
- Detection results for each image
- Precision-Recall curves
- mAP scores
- F1 scores, Recall, and Precision metrics
The model achieves state-of-the-art performance on rodent burrow detection:
- Optimized for high-resolution (3000×3000) Sentinel-2 imagery
- Robust detection of small objects (burrows)
- Improved localization accuracy with GIoU loss
Enable FP16 for faster training with reduced memory:
fp16 = True # in train.pyFor distributed training:
CUDA_VISIBLE_DEVICES=0,1 python -m torch.distributed.launch --nproc_per_node=2 train.pySet distributed = True in train.py.
View model architecture and parameters:
python summary.py- Rodent Burrow Dataset: Available at https://zenodo.org/records/17491180
- Trained Model Weights: Available at https://zenodo.org/records/17491180
- Implementation Code: Available at https://github.com/yeshushahua/CSPS_RetinaNet
If you use this code or dataset in your research, please cite:
@article{sun2025csps,
title={CSPS_RetinaNet: An Enhanced RetinaNet for Rodent Burrow Detection in Grassland Ecosystems},
author={Sun, Haitao and Zou, Songbing and Ji, Zhenqing and Bai, Yajie and Zhang, Wenyong and Gou, Tenghao and Xie, Pengxiang},
journal={},
year={2025},
publisher={}
}This project is licensed under the MIT License - see the LICENSE file for details.
For questions and support, please contact:
- Songbing Zou (Corresponding Author): [email]
- Open an issue on GitHub: https://github.com/yeshushahua/CSPS_RetinaNet/issues
Last Updated: November 2025