Triamorph Systems

Applied AI · 11 min read · Apr 18, 2024

Edge AI Video Analytics in the Browser: Running YOLO and ONNX Runtime Web with WebGL/WebGPU

Technical guide to client-side Edge AI video analytics: compiling YOLOv8 models to ONNX, utilizing ONNX Runtime Web with WebGPU execution providers, and rendering 30 FPS bounding boxes.

By Hammad Haider

Core Engineering Takeaways

  • ONNX Runtime Web with WebGPU execution providers achieves 10x faster inference speeds compared to CPU WebAssembly.
  • Quantizing YOLO models to INT8 shrinks model file weights from 45MB to 8MB without degrading detection accuracy.
  • Client-side video analytics guarantees 100% video privacy because camera video streams never leave the user’s device.

Processing high-definition security camera streams on cloud GPU servers costs thousands per month per camera feed and raises severe privacy concerns. With modern WebAssembly and WebGPU standards, browsers can execute quantized neural network inference directly on the client’s local GPU. This engineering guide demonstrates how to run YOLOv8 object detection in real time at 30+ FPS directly inside a standard web browser using ONNX Runtime Web.

1. The Cloud Video Processing Cost Barrier

Why streaming 24/7 RTSP camera feeds to cloud servers is economically unsustainable

Streaming 1080p video at 30 FPS requires 4 Mbps per camera. For a facility with 20 cameras, streaming to AWS consumes 25 Terabytes of bandwidth monthly plus continuous EC2 GPU compute bills.

Inference Speed
32 FPS
WebGPU ONNX Runtime execution
Model Download Size
8.4MB
YOLOv8n INT8 quantized
Cloud Video Ingestion Cost
$0/mo
100% client-side execution

2. ONNX Runtime Web & WebGPU Pipeline

Initializing WebGPU inference sessions in TypeScript

ONNX Runtime Web binds directly to client GPU compute shaders via the `webgpu` execution provider, running tensor matrix multiplication in parallel.

src/vision/yolo_inference.ts (typescript)
import * as ort from 'onnxruntime-web/webgpu';

export async function createYoloSession(): Promise<ort.InferenceSession> {
  const session = await ort.InferenceSession.create('/models/yolov8n_int8.onnx', {
    executionProviders: ['webgpu'],
    graphOptimizationLevel: 'all',
  });
  return session;
}

3. INT8 Quantization & Pre-Processing with Canvas

Letterbox image resizing and pixel normalization in WebGL shaders

Video frames from `<video>` elements are resized to 640x640 tensors using an offscreen HTML5 canvas, normalizing RGB values to `[0.0, 1.0]` before tensor creation.

4. Non-Maximum Suppression (NMS) & 30 FPS Rendering

Filtering overlapping candidate boxes with IoU thresholds

An optimized TypeScript Non-Maximum Suppression (NMS) function discards redundant candidate boxes, overlaying filtered class labels and confidence scores onto the video canvas at a locked 30 FPS.

Tags: real time computer vision onnx webassemblyedge ai video analytics browseryolo object detection wasm webglclient side computer vision inferenceEdge AI

Related Engineering Practice & Case Studies

Engineering Practice Blueprint

AI Automation & Applied Intelligent Systems →

Production LLM agent integration, computer vision, and Model Context Protocol pipelines.

View Practice Blueprint & Capabilities →
Production Client System

VisageGuard Biometric Security Platform →

Edge facial recognition and biometric identity verification platform with sub-300ms verification latency.

Read Deployed Case Study (99.4% verification accuracy at sub-300ms edge latency) →

Related Engineering Articles & Guides

Explore all technical guides in our Articles & Guides Index → or discuss your architecture with our engineers via Technical Discovery →