Common Preprocessing Failure Modes in Production
Training-Serving Skew
The most common preprocessing failure: training and serving use different preprocessing code. Accuracy drops 10-30% with no obvious error. The model runs, predictions come out, but they are wrong.
Common causes: Different image libraries (PIL vs OpenCV). Different resize interpolation methods. Normalization values hardcoded differently in training and serving code. RGB vs BGR channel order mismatch.
Prevention: Share a single preprocessing function between training and serving. Package preprocessing code with the model artifact. Test that training and serving produce identical tensors for the same input image.
Silent Data Corruption
Truncated images: Partial downloads or disk errors produce incomplete JPEG files. Some decoders crash, others return partial images. Neither behavior is correct for production.
Color profile mismatches: Images with embedded ICC profiles decode differently across libraries. A calibrated photo might render with shifted colors.
Detection: Validate image dimensions after loading. Check for unusual pixel value distributions. Log decode failures separately from inference failures.
Augmentation Bugs
Label-breaking transforms: Horizontal flip is safe for object detection but breaks text recognition. Rotation is safe for single objects but breaks multi-object relationships. Verify augmentations preserve label validity.
Distribution shift: Aggressive augmentation can push images out of natural distribution. Over-rotated, over-blurred images may harm performance. Monitor validation accuracy as you add augmentations.