Skip to content

Repository files navigation

🚁 YOLOv8 UAV Disaster Search & Rescue — Training Pipeline

A complete, modular pipeline for training a YOLOv8 model to detect humans in disaster scenarios using UAV / drone footage.

Dataset: SARD by Roboflow — 1,980 images, 6 classes
Model: YOLOv8s (pretrained COCO → fine-tuned)


📁 Project Structure

D:/MLModel/
├── setup.py              # Install dependencies
├── verify_dataset.py     # Dataset integrity check + class distribution
├── data_uav.yaml         # Dataset config (absolute paths)
├── train.py              # Full training pipeline (UAV-tuned)
├── validate.py           # Post-training evaluation (mAP, confusion matrix)
├── inference.py          # Image / video / folder inference
├── export_model.py       # Export to ONNX / TensorRT / OpenVINO
├── uav_realtime.py       # Real-time OpenCV stream inference
└── README.md             # This file

search-and-rescue-2/
├── data.yaml             # Original Roboflow config (relative paths)
├── train/images + labels/
├── valid/images + labels/
└── test/images  + labels/

🚀 Quickstart

1. Install Dependencies

python setup.py

2. Verify Dataset

python verify_dataset.py

Checks image/label counts, validates YOLO format, prints class distribution.

3. Train

# Full training (100 epochs, GPU)
python train.py

# Smoke test (validate pipeline in 1 epoch)
python train.py --epochs 1 --batch 4 --imgsz 320 --name sar_smoke_test

Best weights → runs/detect/sar_uav/weights/best.pt

4. Validate

python validate.py --weights runs/detect/sar_uav/weights/best.pt

Outputs mAP50, mAP50-95, precision, recall per class + confusion matrix PNG.

5. Run Inference

# Image folder
python inference.py --source D:/MLModel/search-and-rescue-2/test/images

# Drone video
python inference.py --source D:/footage/drone_clip.mp4 --conf 0.15

6. Real-Time UAV Stream

# Webcam
python uav_realtime.py

# RTSP drone stream
python uav_realtime.py --source rtsp://192.168.1.1/stream --conf 0.20

7. Export Model

# ONNX (portable)
python export_model.py --format onnx

# TensorRT (Nvidia Jetson / server GPU)
python export_model.py --format engine --half

📊 Classes

ID Class Priority
0 Running Low
1 Walking Low
2 laying_down 🔴 HIGH — incapacitated victim
3 not_defined Medium
4 seated Medium
5 stands Low

⚙️ UAV-Tuned Hyperparameters

Parameter Value Reason
imgsz 640 Standard; raise to 1280 for very high-alt footage
mosaic 1.0 Tile 4 images → small object diversity
scale 0.6 Simulates altitude change
degrees 15.0 UAV yaw variation
hsv_s 0.7 Haze / smoke robustness
hsv_v 0.4 Day / night variation
flipud 0.3 Nadir vs oblique shots
copy_paste 0.1 Boosts small object recall
patience 20 Early stopping

📈 Improving Recall (Critical for Rescue)

In SAR, missing a victim is worse than a false alarm. Prioritise recall.

  1. Lower confidence threshold: --conf 0.15 at inference time
  2. Class imbalance: Check laying_down count — augment or collect more data
  3. Focal loss: Set fl_gamma=1.5 in train.py DEFAULTS to focus on hard negatives
  4. Larger model: --model yolov8m.pt or yolov8l.pt for more accuracy
  5. Multi-scale training: Try imgsz=1280 if GPU allows (catches smaller subjects)

🔌 Deployment (UAV Integration)

Jetson Nano / TX2

python export_model.py --format engine --half --device 0
python uav_realtime.py --source rtsp://<drone-ip>/stream --headless --save output.mp4

ONNX Runtime (CPU / Cloud)

import onnxruntime as ort, cv2, numpy as np

sess = ort.InferenceSession("best.onnx", providers=["CUDAExecutionProvider"])
frame = cv2.resize(cv2.imread("frame.jpg"), (640, 640))
inp   = (frame[...,::-1].transpose(2,0,1)[None] / 255.).astype("float32")
preds = sess.run(None, {sess.get_inputs()[0].name: inp})

🧪 Transfer Learning Strategy

Strategy Command Notes
COCO pretrained (default) --model yolov8s.pt Best starting point
Full fine-tune (default) Recommended
Freeze backbone Set freeze=10 in train.py Faster, less GPU memory
Resume training --resume Continue from last checkpoint

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages