API Reference

FaceBlurrer

Unified face blurrer wrapping EgoBlur, MediaPipe BlazeFace, and RetinaFace.

class FaceBlurrer:
    SUPPORTED_MODELS = {"egoblur", "mediapipe", "retinaface"}

    def __init__(
        self,
        model: str = "egoblur",
        model_path: str | None = None,
        **kwargs,
    )

All three backends produce identical elliptical-blur output, they differ only in the face detector. See Face blurring guide for the trade-offs.

Constructor

ParamDefaultNotes
model"egoblur"One of {"egoblur", "mediapipe", "retinaface"}.
model_pathNoneRequired for EgoBlur (path to local clone).
**kwargs,Forwarded to the backend's Config.
FaceBlurrer(model="mediapipe")
FaceBlurrer(model="retinaface", network="resnet50")
FaceBlurrer(model="egoblur",    model_path="/opt/EgoBlur")

Methods

load

def load(self) -> None

blur

def blur(self, rgb_or_frame) -> np.ndarray

Detect + blur a single frame. Accepts a SyncedFrame (uses frame.rgb) or a raw (H, W, 3) RGB array. Returns a new RGB array of the same shape and dtype.

blur_batch

def blur_batch(self, frames_or_rgbs: list) -> list[np.ndarray]

Detect + blur a list of frames or RGB arrays. Returns a list aligned with the input.

detect_boxes

def detect_boxes(self, frames_or_rgbs: list) -> list[np.ndarray]

Detection only (no blur). Returns a list of (N, 4) float32 arrays of [x1, y1, x2, y2] boxes per input.

Backend configs

EgoBlurConfig

@dataclass
class EgoBlurConfig:
    egoblur_dir: Optional[str] = None
    model_path: Optional[str] = None      # auto: <egoblur_dir>/ego_blur_face_gen2.jit
    code_dir: Optional[str] = None        # auto: <egoblur_dir>
    device: str = "cuda"
    score_thresh: float = 0.8
    iou_thresh: float = 0.5
    use_fp16: bool = True
    batch_size: int = 8
    scale_factor_detections: float = 1.15

MediaPipeFaceConfig

@dataclass
class MediaPipeFaceConfig:
    min_detection_confidence: float = 0.5
    model_selection: int = 1                 # 0 = short-range, 1 = full-range
    scale_factor_detections: float = 1.15

RetinaFaceConfig

@dataclass
class RetinaFaceConfig:
    network: str = "mobilenet"               # or "resnet50"
    gpu_id: int = 0                          # -1 for CPU
    score_thresh: float = 0.8
    batch_size: int = 8
    scale_factor_detections: float = 1.15

See also