Skip to content

hassan-hfk/Wild-Guard

Repository files navigation

WildGuard — AI Wildlife Detection System

A full-stack wildlife and intrusion detection system built for pond/farm safety. Combines real-time visual detection (YOLO on Raspberry Pi camera), audio classification (YAMNet), Firebase backend, and a Flutter mobile app for remote alerts and control.


System Architecture

┌─────────────────────────────────┐        ┌──────────────────────┐
│     Raspberry Pi 5 (Edge)       │        │   Flutter Mobile App │
│                                 │        │                      │
│  ┌─────────────┐  ┌──────────┐  │        │  - Live alerts       │
│  │ YOLO Camera │  │ YAMNet   │  │◄──────►│  - Detection history │
│  │ Detection   │  │ Audio    │  │Firebase│  - Arm/disarm        │
│  └─────────────┘  └──────────┘  │        │  - Auth (email/      │
│           │             │       │        │    Google)           │
│           └──────┬──────┘       │        └──────────────────────┘
│                  ▼              │
│           Firebase Firestore    │
│           (detections +         │
│            commands)            │
└─────────────────────────────────┘

Components

1. RPi Backend (rpi-backend/)

Runs on Raspberry Pi 5. Listens for trigger commands from Firebase, then performs:

  • Camera detection — YOLO (NCNN format) via Picamera2, detects animals/persons
  • Audio classification — YAMNet embeddings → custom Keras classifier, detects animal sounds

2. YAMNet Audio Classifier (audio-classifier/)

Training pipeline for the animal sound classification model:

  • Extracts YAMNet embeddings from ESC-50 dataset audio
  • Trains a lightweight Dense classifier on top
  • Exports .keras model + label encoder for deployment on RPi

3. Flutter App (flutter-app/)

Cross-platform mobile/web app (Android, iOS, Web):

  • Firebase Auth (email/password + Google Sign-In)
  • Real-time detection alerts via Firebase Cloud Messaging
  • Detection history from Firestore
  • Remote trigger control (camera / voice mode)

Setup

RPi Backend

cd rpi-backend
pip install -r requirements.txt

Set up Firebase credentials:

# Download your service account key from:
# Firebase Console → Project Settings → Service Accounts → Generate new private key
# Save as firebase_credentials.json (never commit this file)
export FIREBASE_CREDENTIALS=firebase_credentials.json
export YOLO_MODEL_PATH=models/best_ncnn_model
export CLASSIFIER_PATH=models/final_animal_classifier.keras
export ENCODER_PATH=models/label_encoder_classes.npy

python main.py

Audio Classifier Training

cd audio-classifier
pip install -r requirements.txt

# 1. Download ESC-50 dataset: https://github.com/karolpiczak/ESC-50
# 2. Place audio files in audio/ and esc50.csv in this directory
# 3. Extract and organize audio files
python extracting_audio_files.py

# 4. Train the YAMNet-based classifier
python YAMnet_embeddings.py

# 5. Test real-time classification
python test_voice_classification.py

Flutter App

cd flutter-app
flutter pub get

Configure Firebase:

  1. Create a Firebase project at https://console.firebase.google.com
  2. Add Android/iOS/Web apps to your project
  3. Download google-services.json (Android) and GoogleService-Info.plist (iOS)
  4. Update the web config in lib/main.dart with your project credentials
  5. Run:
flutter run

Hardware (RPi Backend)

  • Raspberry Pi 5 (8GB recommended)
  • Raspberry Pi Camera Module 3
  • USB microphone or I2S microphone
  • Stable internet connection for Firebase

Models

Model Purpose Format
YOLOv8 (custom trained) Visual animal/person detection NCNN (RPi optimized)
YAMNet + Dense classifier Animal sound classification Keras .keras

Model weights are not included in this repo (too large). Train your own using the scripts in audio-classifier/ or contact for pre-trained weights.


License

MIT — free to use, modify, and distribute.

About

AI wildlife detection system : YOLO + YAMNet on Raspberry Pi with Flutter mobile app and Firebase

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors