Skip to content

Cloud-Jas/GemmaGuardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”’ GemmaGuardian AI Surveillance System

Python License Status

Transform any camera into an intelligent AI-powered surveillance system

πŸš€ Quick Start β€’ πŸ“– Documentation β€’ πŸ“±Mobile App β€’ 🀝 Contributing

🌟 Overview

GemmaGuardian converts any RTSP camera into an intelligent surveillance system using Google's Gemma models. It eliminates false positives through AI-powered analysis and provides professional-grade threat assessment with mobile integration.

πŸ“š Complete Guides

  • πŸš€ Setup Guide - Complete installation and configuration
  • πŸ—οΈ System Architecture - Technical deep dive with official architecture diagram
  • πŸ”§ Network Setup - Firewall, ports, and network configuration

Key Features

  • 🧠 Dual AI Modes: Ollama server-based or direct transformer processing
  • πŸ“Ή Universal Camera Support: Works with any RTSP-enabled camera
  • 🚨 Intelligent Alerts: Context-aware threat classification (Critical/High/Medium/Low)
  • πŸ“± Mobile App: Complete Android companion with live streaming
  • πŸ”’ Privacy-First: Local processing, no cloud dependency required
  • ⚑ Real-time Processing: <100ms person detection, 30-60s analysis

πŸ—οΈ System Architecture

GemmaGuardian System Architecture

Complete GemmaGuardian system flow from RTSP input through AI processing to mobile notifications and storage.

graph TD
    A[πŸ“Ή RTSP Stream Input] --> B[πŸ” Real-time Person Detection MobileNet SSD]
    B --> C{πŸ‘€ Person Detected?}
    C -->|Yes Confidence > 0.5| D[πŸ“Ή Record 60s HD Security Clip]
    C -->|No| B
    D --> E[πŸ–ΌοΈ Extract Frames Every 2 Seconds]
    E --> F[πŸ“ Resize to 1024x1024 Resolution]
    F --> G[πŸ“¦ Group into Batches of 4 Frames]
    G --> H[🧠 AI Mode Selection]
    
    H --> I[🌐 Ollama Mode]
    H --> J[πŸ”₯ Transformer Mode]
    
    I --> I1[πŸ“‘ Send to Ollama Server]
    I1 --> I2[🎯 Gemma 3 4b Vision Analysis]
    I2 --> I3[πŸ“ Gemma 3n e2b Consolidation]
    I3 --> K[πŸ›‘οΈ Security Assessment]
    
    J --> J1[πŸ’Ύ Load Model to GPU/CPU]
    J1 --> J2[πŸš€ Direct PyTorch Inference]
    J2 --> J3[πŸ”§ Memory-Optimized Processing]
    J3 --> K
    
    K --> L[πŸ“Š Threat Classification]
    L --> M{⚠️ Threat Level?}
    M -->|Critical/High| N[🚨 Immediate Alert]
    M -->|Medium/Low| O[πŸ“‹ Activity Log]
    N --> P[πŸ“± Mobile Notification]
    O --> P
    P --> Q[πŸ’Ύ Database Storage]
    Q --> R[πŸ“ Archive & Cleanup]
    R --> B
    
    subgraph "🧠 AI Processing Comparison"
        AI1[Ollama: Server-based Client-Server]
        AI2[Transformer: Direct In-Process]
        AI3[Both: Anti-hallucination Validation]
        H --> AI1
        H --> AI2
        AI1 --> AI3
        AI2 --> AI3
    end
Loading

Mobile Application Integration

Professional Android companion with local network connectivity:

Home Screen
πŸ“± Home Dashboard
Live Feed
πŸ“Ή Video Feed
Alerts
🚨 Alert Management
Alerts
πŸ”’ Technical Details

Key Features:

  • πŸ“± Real-time RTSP Streaming: Direct camera feed access within LAN
  • πŸ”” UDP Broadcast Alerts: Instant notifications via local network
  • πŸ“Š AI Analysis Dashboard: Historical threat assessments and statistics
  • βš™οΈ Remote Configuration: System settings via local API calls

πŸš€ Quick Start

⭐ One-Command Complete Setup (Recommended)

The setup.py script is your gateway to GemmaGuardian - it handles EVERYTHING automatically:

python setup.py

🎯 What this powerful script accomplishes:

  1. βœ… Environment Setup: Creates virtual environment and installs all dependencies
  2. βœ… Model Downloads: Downloads MobileNet SSD and Gemma AI models automatically
  3. βœ… AI Mode Configuration: Guides you through Ollama or Transformer mode setup
  4. βœ… Network Configuration: Sets up firewall rules for camera and mobile access
  5. βœ… System Testing: Runs comprehensive tests to verify everything works
  6. βœ… Camera Setup: Prompts for your RTSP URL and validates connection
  7. βœ… Auto-Launch: Optionally starts the surveillance system immediately

πŸš€ After running setup.py, your surveillance system will be fully operational!

πŸ’‘ Pro Tip: The setup script includes intelligent error handling, GPU detection, and guided configuration - making professional surveillance setup accessible to everyone.

πŸ”₯ Important: Firewall Configuration

GemmaGuardian requires specific network ports for mobile connectivity:

# Windows (Run as Administrator) - Automated Setup
cd src/SurveillanceAgent
.\setup_firewall.ps1
# Linux/Ubuntu - Manual Setup
sudo ufw allow 37020/udp    # UDP broadcast notifications  
sudo ufw allow 8888/tcp     # REST API server
sudo ufw reload

⚠️ Critical: Without proper firewall configuration, the mobile app won't receive notifications or connect to the surveillance system.

πŸ“– Detailed Setup Guide: docs/SETUP_GUIDE.md

System Requirements

  • Python 3.8+
  • 8GB+ RAM (16GB recommended)
  • RTSP Camera (IP camera, NVR, or mobile app)
  • GPU (optional, for Transformer mode acceleration)

πŸ“– Documentation

πŸ“š Complete Guides

πŸ”Œ Integration & Development

⚑ Quick Actions

Firewall Setup (Windows - Run as Administrator)

# Automated firewall configuration
cd src/SurveillanceAgent
.\setup_firewall.ps1

Manual System Start

cd src/SurveillanceAgent
python main.py --mode ollama    # or --mode transformer

πŸ“± Mobile App

Professional Android companion app with enterprise-grade features:

  • πŸ“Ή Live Streaming: Real-time RTSP feed viewing
  • πŸ”” Smart Notifications: Threat-level based alerts only
  • πŸ“Š Analysis History: Browse and search security events
  • βš™οΈ Remote Control: Configure system from anywhere
  • 🚨 Emergency Alerts: Critical threat escalation

πŸ“² Quick Install

Ready-to-install APK: Download the pre-built Android app directly from docs/gemmaguardian.apk

πŸ“± Mobile App Setup: src/MobileApp/README.md

πŸ”§ Essential Configuration

πŸ”₯ Automated Firewall Setup (Windows)

# Run the provided PowerShell script as Administrator
cd src/SurveillanceAgent
.\setup_firewall.ps1

πŸ“‹ Complete Configuration Guide: docs/SETUP_GUIDE.md

πŸ§ͺ Testing & Validation

# Quick system test
cd src/SurveillanceAgent
python test_setup.py

# AI model validation
python test_ai_flow.py

🀝 Contributing

We welcome contributions! Areas of focus:

  • 🎯 New AI models and detection algorithms
  • πŸ“± Mobile app enhancements
  • πŸ”” Additional notification channels
  • πŸ“Š Analytics and reporting features
  • 🐳 Container and deployment improvements

Development Setup: docs/SETUP_GUIDE.md#manual-installation-advanced-users

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Google: Gemma model family
  • Ollama: Model serving platform

πŸ”— Links: GitHub β€’ Issues β€’ Discussions

About

Gemma Guardian - Transform any camera into an intelligent AI-powered surveillance system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages