Frame Processor

1. Create

Create a new example file:
facefusion/processors/frame/modules/example.py

2. Implement

Define the frame processor inputs type:
ExampleInputs = TypedDict('ExampleInputs',
{
'reference_faces' : FaceSet,
'source_face' : Face,
'target_vision_frame' : VisionFrame
})
Implement the required hooks of the frame processor:
from typing import Any, List, Literal, Optional
from argparse import ArgumentParser
from facefusion.typing import Face, VisionFrame, Update_Process, ProcessMode, ModelSet, OptionsWithModel
from facefusion.processors.frame.typings import ExampleInputs
FRAME_PROCESSOR = None
NAME = __name__.upper()
MODELS : ModelSet = {}
OPTIONS : Optional[OptionsWithModel] = None
def get_frame_processor() -> Any:
pass
def clear_frame_processor() -> None:
pass
def get_options(key : Literal['model']) -> Any:
pass
def set_options(key : Literal['model'], value : Any) -> None:
pass
def register_args(program : ArgumentParser) -> None:
pass
def apply_args(program : ArgumentParser) -> None:
pass
def pre_check() -> bool:
return True
def post_check() -> bool:
return True
def pre_process(mode : ProcessMode) -> bool:
pass
def post_process() -> None:
pass
def get_reference_frame(source_face : Face, target_face : Face, temp_vision_frame : VisionFrame) -> VisionFrame:
pass
def process_frame(inputs : ExampleInputs) -> VisionFrame:
pass
def process_frames(source_path : str, temp_frame_paths : List[str], update_progress : Update_Process) -> None:
pass
def process_image(source_path : str, target_path : str, output_path : str) -> None:
pass
def process_video(source_path : str, temp_frame_paths : List[str]) -> None:
pass

3. Done

Finally, run the command:
python run.py --frame-processors example
Last modified 18d ago