Closed KRSHH closed 3 weeks ago
This PR implements significant performance improvements to the webcam preview and face swapping functionality. The changes focus on optimizing camera settings, implementing adaptive frame processing, adding virtual camera support, and enhancing face swapping performance through better VRAM utilization and face caching.
sequenceDiagram
participant User
participant UI
participant Camera
participant FrameProcessor
participant VCam
User->>UI: Start webcam preview
UI->>Camera: Initialize with optimized settings
Camera-->>UI: Return camera dimensions
UI->>VCam: Initialize virtual camera
loop Every frame
Camera->>UI: Capture frame
UI->>FrameProcessor: Process frame
FrameProcessor-->>UI: Return processed frame
UI->>VCam: Send frame to virtual camera
VCam-->>UI: Confirm frame sent
end
User->>UI: Stop webcam preview
UI->>Camera: Release camera
UI->>VCam: Release virtual camera
classDiagram
class FrameProcessor {
+process_frame(source_face: Face, temp_frame: Frame) : Frame
+process_frame_v2(temp_frame: Frame) : Frame
+_cache: dict
}
class FaceSwapper {
+get_face_swapper() : Any
+swap_face(source_face: Face, target_face: Face, temp_frame: Frame) : Frame
}
FrameProcessor --> FaceSwapper
note for FrameProcessor "Added caching for repeated faces"
note for FaceSwapper "Set optimal inference parameters for VRAM usage"
Change | Details | Files |
---|---|---|
Implemented optimized webcam capture and virtual camera support |
|
modules/ui.py |
Added adaptive frame processing for performance optimization |
|
modules/ui.py |
Enhanced face swapping performance and quality |
|
modules/processors/frame/face_swapper.py |
@sourcery-ai review
Summary by Sourcery
Enhance the webcam preview functionality by introducing a virtual camera feature and optimizing performance through dynamic scaling and caching. Improve camera initialization settings for better frame processing efficiency.
New Features:
Enhancements: