The InferenceAgent is the primary class for executing inference. It loads the IMTRenderer and FMGenerator models and provides two main modes of operation.
Audio-driven Inference (run_audio_inference)
Generates a talking face video from a single source image and an audio file.
Parameters:
img_pil: Source image as a PIL object.aud_path: Path to the driving audio file.crop: Whether to apply automatic face cropping.seed: Random seed for reproducibility.nfe: Number of function evaluations.cfg_scale: CFG scale.
Video-driven Inference (run_video_inference)
Generates a talking face video by transferring motion from a driving video to a source image.
Parameters:
source_img_pil: Source image as a PIL object.driving_video_path: Path to the video containing the motion to drive the face.crop: Whether to apply automatic cropping to both source and driving inputs.
# Example usage concept
agent = InferenceAgent(cfg)
# Audio-driven
result_video = agent.run_audio_inference(img_pil, "audio.wav", crop=True, seed=42, nfe=10, cfg_scale=2.0)
# Video-driven
result_video = agent.run_video_inference(img_pil, "driving.mp4", crop=True)