Move hot-path imports to module scope

Address Sourcery review feedback: move face_align and get_one_face
imports from inside per-frame functions to module-level to avoid
repeated attribute lookup overhead in the processing loop.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Max BuckleyandClaude Opus 4.6 committed 2026-04-09 14:34:53 +02:00
1 parent bcdd0ce2dd
commit 646b0f816f
2 files changed
+2 -3

No files matched your search

+1 -1
View File
@@ -1,6 +1,7 @@
from typing import Any, List, Optional
import cv2
import insightface
from insightface.utils import face_align
import threading
import numpy as np
import platform
@@ -241,7 +242,6 @@ def swap_face(source_face: Face, target_face: Face, temp_frame: Frame) -> Frame:
return original_frame
# Get the aligned input crop for the mask (same as insightface does internally)
from insightface.utils import face_align
aimg, _ = face_align.norm_crop2(temp_frame, target_face.kps, face_swapper.input_size[0])
swapped_frame = _fast_paste_back(temp_frame, bgr_fake, aimg, M)