Cloudflare

How we built AI face cropping for Images

Aug 20, 2025Deanna Lam, Diretnan Domnan
How we built AI face cropping for Images
SummaryAI, from the source post

This post details the engineering effort behind bringing AI face cropping to Cloudflare Images. It describes the transition from a CPU-based prototype to a GPU-based implementation using Workers AI to address scalability and memory leak issues. The technical details include the selection of the RetinaFace model for face detection, its performance characteristics on the WIDERFACE dataset, and the inference process including image resizing to 1024x1024 for efficiency. It also explains how bounding boxes are used to construct an outer bounding box for cropping and the use of the `gravity=face` and `zoom` parameters for image transformation.

More from the Artificial Intelligence Integration & Impact trail