YOLO and Redis: how to cache video detection results
YOLO processes video, but after a network or camera failure everything starts over — wasting GPU time. Caching in Redis stores detection results for each frame,

When processing a video stream with YOLO, you encounter an unpleasant problem: you start a forty-minute video, the model faithfully detects people, cars, dogs in each frame. At the twenty-minute mark, the network drops, a surveillance camera fails, or the power simply goes out. You restart the system. And here's the problem: YOLO starts processing the video from scratch, from the very beginning. All twenty minutes of inference repeat, the GPU grinds uselessly, and thus time and electrical resources are lost.
Why This Hurts
Every pass of YOLO through a video frame requires computational power. On GPU this is expensive — literally consuming energy, figuratively stalling processing and falling behind schedule. Without caching, the system doesn't remember what it has already computed.
It's like recalculating from scratch: if processing was at frame 1200, and then the server crashes, on restart you begin at frame 0 and find people and cars in the first 1200 frames all over again. At the same time, you lose tracking information — object IDs over that video segment. If you need to track a specific person through the entire video, data loss means trajectory breaks and mixed IDs between objects.
The problem is compounded by scale: on half-day surveillance where 100+ hours of footage is processed per day, losing progress means a proportional increase in costs.
Caching in Redis
Redis is an in-memory storage that works fast (millisecond latency). The idea: remember detection results for each frame and recover on restart. The system caches:
- Detection results for each frame (list of objects, their coordinates, class)
- Track-ID for each object between frames (connection between the same object in adjacent frames)
- Processing timestamps (when each frame was processed)
- Processing status (which frame was the last completed one)
On restart, the system checks Redis, finds the last processed frame, and continues from that point. GPU doesn't spend time on repeated inference for old frames, only new ones.
Practical Solution
The article offers ready-to-use Python snippets that can be copied and used immediately. The code solves three tasks:
- Caching YOLO results in Redis with a key like `video:{video_id}:frame:{frame_num}` and TTL for cleanup of old data
- Recovery on restart: the system checks Redis, skips already-processed frames, starts with the new one
- Tracking object IDs between frames with link storage in cache
The author shares real-world experience: the system becomes fault-tolerant, video is processed without loss of data about object trajectories. In practice, GPU saves 30–50% of processing time on long videos by skipping repeated inference.
What This Means
For production video analytics systems, this is critical. Surveillance cameras, sports analytics, autonomous systems — everywhere YOLO + Redis saves time and money on electricity and compute. Just add Redis to the architecture, and network failures become a forgotten problem.