Back to articles
AI & Cloud

Building a Smart Face Recognition and Motion Detection System with Frigate AI on GPU VPS

A detailed guide to building a smart surveillance system with Frigate AI on GPU VPS, integrating face recognition and motion detection, optimizing performance and cost for small...

DPTCloud Engineering4 min read
Building a Smart Face Recognition and Motion Detection System with Frigate AI on GPU VPS

Building a Smart Surveillance System with Frigate AI on GPU VPS

In the digital age, deploying intelligent security surveillance systems has become essential for small businesses, offices, and homes. With AI advancements, Frigate AI has emerged as a powerful self-hosted solution for real-time motion detection and face recognition from IP cameras, running efficiently on GPU VPS. This guide walks you through building a smart surveillance system with Frigate AI, optimizing both performance and cost.

Introduction to Frigate AI

Frigate AI is a self-hosted video surveillance system that integrates AI for motion detection and face recognition. Based on Frigate's GitHub, the system uses TensorFlow Lite or ONNX for real-time video analysis, supports multiple IP cameras, and sends alerts via email, MQTT, or mobile apps.

Notably, Frigate AI supports GPU acceleration to speed up image processing, enabling the system to handle multiple cameras simultaneously without lag. With a GPU VPS setup, you can deploy this system without investing in expensive hardware.

Prerequisites Before Deployment

To build the system, you will need:

  • A GPU-enabled VPS with CUDA support (minimum 8GB RAM, NVIDIA T4 or RTX 30xx GPU)
  • IP cameras supporting RTSP (e.g., Hikvision, Dahua)
  • OS: Ubuntu 22.04 LTS or Debian 11
  • Docker and Docker Compose installed

Refer to the Docker installation guide at: High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways.

Deploying Frigate AI on GPU VPS

We will use Docker to deploy Frigate AI. Create a docker-compose.yml file with the following content:

version: '3.8'

services:
  frigate:
    container_name: frigate
    image: cr.frigate.video/frigate:stable-amd64
    runtime: nvidia
    restart: unless-stopped
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config:/config
      - ./recordings:/recordings
      - /dev/bus/usb:/dev/bus/usb
    ports:
      - "5000:5000"
      - "1935:1935" # RTMP
    devices:
      - /dev/dri:/dev/dri
    environment:
      - FRIGATE_CAMERA__CAMERA1__RTSP_URL=rtsp://username:[email protected]:554/stream1
      - FRIGATE_CAMERA__CAMERA1__FPS=5
      - FRIGATE_CAMERA__CAMERA1__WIDTH=1280
      - FRIGATE_CAMERA__CAMERA1__HEIGHT=720
      - FRIGATE_CAMERA__CAMERA1__MODEL=face
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__ENABLED=true
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__CONFIDENCE=0.6
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__THRESHOLD=0.6
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__RECOGNITION__ENABLED=true
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__RECOGNITION__DATABASE=/config/face_database.db
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__RECOGNITION__MODEL=vgg-face
      - FRIGATE_CAMERA__CAMERA1__MODEL__DETECTIONS__FACE__RECOGNITION__SIMILARITY_THRESHOLD=0.6
    cap_add:
      - SYS_ADMIN
      - DAC_READ_SEARCH

Replace rtsp://username:[email protected]:554/stream1 with your camera’s RTSP URL. The configuration enables motion detection and face recognition with 60% confidence.

Motion Detection and Face Recognition

Frigate AI analyzes video frame by frame. When motion is detected, the system:

  • Creates a short clip (10 seconds)
  • Saves it to the /recordings folder
  • Compares faces against a registered database
  • Sends alerts via MQTT or email if a known person is recognized

To enable face recognition, you need to train the model. Use face_recognition to build a face database. Example:

import face_recognition
import cv2

# Load images of known faces
known_face_encodings = []
known_face_names = []

# Add known faces
image = face_recognition.load_image_file("person1.jpg")
encoding = face_recognition.face_encodings(image)[0]
known_face_encodings.append(encoding)
known_face_names.append("John")

# Save to database
import pickle
with open("/config/face_database.db", "wb") as f:
    pickle.dump({"encodings": known_face_encodings, "names": known_face_names}, f)

Verification and Troubleshooting

To verify the system is working:

  1. Open a browser and go to http://:5000
  2. Check if cameras are displayed
  3. Run the command to view logs:
docker logs frigate -f

If cameras are not visible, check:

  • Is the RTSP path correct?
  • Is RTSP enabled on the camera?
  • Is the GPU recognized by Docker?

Refer to: Build a New Generation AI Voice Assistant with Piper TTS and Whisper on ARM VPS.

Conclusion

With Frigate AI on GPU VPS, you can build a smart surveillance system for face recognition and motion detection at low cost. The self-hosted setup ensures data security, full control, and optimized performance through GPU acceleration.

Learn more: Dedicated Compute Servers for AI & Inference Workloads.

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478