000%
ホームに戻る
Computer Vision

YOLO in Production: What Actually Breaks

2024-12-2811 min read

From 94% notebook accuracy to 30 FPS on a Jetson—what nobody tells you

Training a YOLO model to 94% mAP on a balanced test set feels like success. Then you try to deploy it on edge hardware running at 30 FPS under real-world lighting conditions and everything breaks. Inference is too slow. Accuracy drops. The model drifts on new data. This article is about the gap between notebook metrics and production performance—and how to close it.

The Notebook vs Production Gap

In notebooks, you train on clean, labeled data with balanced classes. Inference runs on a GPU with no latency constraints. You evaluate on a static test set that looks like your training data.

In production, data is messy and imbalanced. Inference runs on constrained hardware (Jetson Nano, Coral, or CPU) with strict latency budgets. Real-world conditions—lighting, angles, occlusions—don't match your training set. And new object variants appear over time, causing drift.

What Actually Breaks in Production

  • Inference latency: Your model runs at 15 FPS on the target hardware. You need 30. Optimization (quantization, pruning, TensorRT) can help, but often requires accuracy trade-offs.
  • Accuracy degradation: Real-world conditions differ from training data. Lighting changes, camera angles, wear-and-tear on objects—all cause accuracy to drop from 94% to 80%.
  • Class imbalance: Rare defects or objects make up <1% of production data. Your model, trained on balanced data, misses them. Confidence thresholds need per-class tuning.
  • Hardware constraints: Edge devices have limited memory, compute, and power. Models that run fine on a 3090 crash or throttle on a Jetson Nano.
  • Drift: New object variants, environmental changes, or camera wear cause model performance to degrade over time. Without monitoring, you don't notice until it's too late.
  • False positives: In production, false positives are costly (wasted inspections, alert fatigue). Your test set doesn't capture this because it's artificially balanced.

Optimization for Edge Deployment

Model selection matters: YOLOv9-small might outperform YOLOv8-medium on edge hardware due to better speed/accuracy trade-off. Benchmark on your target hardware, not on your training GPU.

Quantization: Convert from FP32 to INT8 using TensorRT or ONNX quantization. This often gives 2-4x speedup with minimal accuracy loss (<2% mAP drop). Calibrate on representative production data, not just your test set.

Input resolution: Training at 640x640 but running inference at 416x416 can double FPS with acceptable accuracy loss. Test multiple resolutions on real-world data.

Batching: If you're processing a video stream, batch frames for inference. Batch size of 4-8 can improve throughput on edge GPUs without much latency increase.

Handling Drift and Retraining

Production models drift. New variants, environmental changes, or camera issues cause performance to degrade over time. You need monitoring to catch this before it impacts operations.

Log every inference: save image, detected boxes, confidence scores. Track confidence distributions over time. If mean confidence drops or false positive rate spikes, it's a signal.

Automate retraining triggers: when drift is detected (e.g., confidence distribution shifts beyond threshold), flag for retraining. Incorporate recent production images into the training set.

Human-in-the-loop labeling: Not all production images need labeling—only the ones where the model is uncertain (low confidence) or wrong (flagged by humans). This reduces labeling cost while improving the dataset.

Per-Class Confidence Tuning

In production, class imbalance is real. Rare defects or objects need different confidence thresholds than common ones. A global threshold of 0.5 might work for frequent classes but miss rare ones entirely.

Solution: tune confidence thresholds per class. For rare critical defects, lower the threshold to increase recall (catch more positives) even if it increases false positives. For common classes, keep thresholds high to reduce noise.

This requires production data to calibrate properly—your test set won't reflect real-world class distributions.

The Bottom Line

YOLO in production is not just about training accuracy. It's about inference speed on constrained hardware, robustness to real-world conditions, monitoring for drift, and retraining workflows.

If you're deploying vision models to production, test on target hardware early. Optimize for speed and memory. Log everything. Monitor for drift. Build retraining pipelines before you need them. That's the difference between a model that works in a notebook and a system that works in production.