To achieve high-quality face alignment and cropping, use tools like MTCNN or dlib for precise facial landmark detection and affine transformations.
Here is the code snippet you can refer to:

In the above code, we are using the following key points:
- Precise Face Detection: Uses dlib for accurate facial landmark extraction.
- Automatic Face Alignment: Aligns eyes horizontally to maintain consistency.
- Affine Transformations: Ensures uniform positioning across the dataset.
- High-Quality Cropping: Extracts only the face region for deepfake training.
- Scalability: Works on large datasets for batch processing.
Hence, by referring to the above, you can ensure high-quality face alignment and cropping when preparing datasets for a deepfake generation.