How we built AI face cropping for Images
Aug 20, 2025Deanna Lam, Diretnan Domnan

Summary
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
- Introducing Clef-omni with full multimodality, plus a faster Clef and a cheaper Clef-flash
- Introducing Web Search API via AI Gateway
- Introducing Clef: our open-source decision models, and new RL fine-tuning platform
- One year later: Sovereign AI and the fight for choice
- AI Search is now generally available