# FaceSwap Centering Options: Understanding Legacy, Face, and Head Modes

> Explore FaceSwap centering modes legacy face and head to optimize your training images. Understand how nose tip face geometry and full skull alignment affect context.

- Repository: [deepfakes/faceswap](https://github.com/deepfakes/faceswap)
- Tags: how-to-guide
- Published: 2026-03-06

---

**FaceSwap provides three centering modes—`legacy`, `face`, and `head`—that control whether the crop centers on the nose tip, the face geometry, or the full skull, directly impacting how much surrounding context appears in aligned training images.**

The `deepfakes/faceswap` repository implements sophisticated face alignment algorithms that use specific FaceSwap centering options to determine how facial crops are extracted from source images. These settings affect the positioning of facial landmarks within the extracted frame and influence the amount of head and background context included in the training data.

## What Are FaceSwap Centering Options?

FaceSwap centering options are defined by the `CenteringType` type alias in [`lib/align/constants.py`](https://github.com/deepfakes/faceswap/blob/main/lib/align/constants.py), which supports three string values: `"legacy"`, `"face"`, and `"head"`. The centering mode determines the geometric anchor point used when cropping and aligning faces, establishing how the detected facial landmarks translate to pixel coordinates in the output image.

Each mode corresponds to a specific **padding ratio** defined in the `EXTRACT_RATIOS` dictionary within the same constants file. These ratios—`0.375` for legacy, `0.5` for face, and `0.625` for head—represent the proportion of padding applied around the central anchor point, effectively controlling the field of view in the extracted face crop.

## The Three FaceSwap Centering Modes

### Legacy Centering

**Legacy centering** places the **nose tip** at the exact center of the aligned image. This method represents the original alignment approach used in early FaceSwap versions and utilizes a padding ratio of `0.375` (37.5%), resulting in a tighter crop that focuses primarily on the central face region with minimal surrounding head area.

### Face Centering

**Face centering** centers the crop on the **face geometry** itself—keeping the nose vertically centered while horizontally aligning to the middle of the skull. With a padding ratio of `0.5` (50%), this mode yields a balanced composition that maintains facial focus while including more contextual head information than legacy mode.

### Head Centering

**Head centering** positions the crop center on the **skull in 3D space**, providing the widest field of view among the three options. Using a padding ratio of `0.625` (62.5%), this mode captures substantial hair, ears, and background context, making it ideal when the model needs to learn head shape and surrounding environmental details.

## Technical Implementation in the FaceSwap Codebase

The core alignment logic resides in [`lib/align/aligned_face.py`](https://github.com/deepfakes/faceswap/blob/main/lib/align/aligned_face.py), which implements the `AlignedFace` class and utility functions `get_centered_size()` and `get_adjusted_center()`. When initializing an `AlignedFace` object, the `centering` parameter accepts any valid `CenteringType` value to determine the transformation matrix applied to the source landmarks.

The `get_centered_size()` function calculates the dimensions of sub-crops when converting between different centering modes, while `get_adjusted_center()` computes the pixel coordinate translations required to shift the anchor point from one centering type to another. These functions reference the `EXTRACT_RATIOS` defined in [`lib/align/constants.py`](https://github.com/deepfakes/faceswap/blob/main/lib/align/constants.py) to ensure consistent scaling across different extraction configurations.

Additional components respect these centering settings throughout the pipeline:
- [`tools/mask/mask_output.py`](https://github.com/deepfakes/faceswap/blob/main/tools/mask/mask_output.py) handles mask generation using the specified centering offset
- [`tools/preview/viewer.py`](https://github.com/deepfakes/faceswap/blob/main/tools/preview/viewer.py) propagates centering configuration to preview displays
- [`tools/manual/faceviewer/viewport.py`](https://github.com/deepfakes/faceswap/blob/main/tools/manual/faceviewer/viewport.py) applies centering when rendering thumbnails in the manual extraction interface

## Working with FaceSwap Centering in Python

### Creating Aligned Faces with Specific Centering

Instantiate the `AlignedFace` class with the `centering` parameter to control the extraction anchor point:

```python
from lib.align.aligned_face import AlignedFace

# Example landmarks (68-point) extracted from a source image

landmarks = ...  # np.ndarray shape (68, 2)

# Legacy centering – nose tip at image center

legacy_face = AlignedFace(landmarks, centering="legacy")

# Face centering – nose vertical center, skull horizontal center

face_centered = AlignedFace(landmarks, centering="face")

# Head centering – skull center in both axes

head_centered = AlignedFace(landmarks, centering="head")

```

### Converting Between Centering Modes

Calculate the crop size when transitioning from one centering mode to another using `get_centered_size()`:

```python
from lib.align.aligned_face import get_centered_size

source = "legacy"   # image was aligned using legacy centering

target = "head"     # we want a head-centered sub-crop

src_size = 256      # original aligned image size (pixels)

crop_size = get_centered_size(source, target, src_size)
print(f"Sub-crop size for {target} centering: {crop_size}px")

```

### Adjusting Center Coordinates

Translate pixel coordinates between different centering modes using `get_adjusted_center()`:

```python
from lib.align.aligned_face import get_adjusted_center

src_center = "legacy"
dst_center = "face"
size = 256
y_offset = 0.0

# Calculate new center pixel for target centering mode

new_center = get_adjusted_center(
    image_size=size,
    source_offset=PoseEstimate().offset[src_center],
    target_offset=PoseEstimate().offset[dst_center],
    source_centering=src_center,
    y_offset=y_offset,
)

print(f"New center pixel for {dst_center} centering: {new_center}")

```

## Summary

- FaceSwap centering options control the geometric anchor point for face extraction, with three modes available: `legacy`, `face`, and `head`
- **Legacy** centering (`0.375` padding ratio) centers on the nose tip for tight facial crops
- **Face** centering (`0.5` padding ratio) balances the nose and skull center for moderate context
- **Head** centering (`0.625` padding ratio) centers on the skull for maximum head and background inclusion
- The [`lib/align/constants.py`](https://github.com/deepfakes/faceswap/blob/main/lib/align/constants.py) file defines `CenteringType` and `EXTRACT_RATIOS`, while [`lib/align/aligned_face.py`](https://github.com/deepfakes/faceswap/blob/main/lib/align/aligned_face.py) implements the core transformation logic
- Use `get_centered_size()` and `get_adjusted_center()` to programmatically convert between different centering modes

## Frequently Asked Questions

### What is the default centering mode in FaceSwap?

Modern FaceSwap versions typically default to `face` centering, though `legacy` remains available for backward compatibility with older training sets extracted using the nose-tip alignment method. You can specify the centering mode explicitly when creating `AlignedFace` instances or through command-line arguments in the extraction tools.

### How does centering affect model training quality?

The centering mode directly influences what contextual information the model learns. **Legacy** and **face** centering work well for facial expression transfer where tight focus on features matters, while **head** centering improves results when the model must account for hair, ears, or head pose variations. Inconsistent centering between training and conversion phases causes alignment mismatches that degrade output quality.

### Can I convert existing aligned faces to a different centering without re-extracting?

Yes, use the `get_centered_size()` function to calculate the appropriate crop dimensions and `get_adjusted_center()` to determine the coordinate offset when converting between centering modes. However, this effectively crops the existing alignment, so switching from `legacy` to `head` centering on an existing image will reduce resolution rather than reveal new content outside the original bounds.

### Which centering option provides the best results for deepfake generation?

**Face** centering generally offers the optimal balance for most deepfake workflows, providing enough context for natural head movement while maintaining focus on facial features. Use **head** centering when training models that must handle significant hair coverage or profile views, and reserve **legacy** centering only when maintaining compatibility with legacy workflows or when processing already-extracted legacy datasets.