mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-28 12:59:03 +02:00
avoid tobytes copy (#1208)
This commit is contained in:
@@ -11,7 +11,7 @@ FACE_STORE : FaceStore = {}
|
||||
|
||||
def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]:
|
||||
if numpy.any(vision_frame):
|
||||
vision_hash = create_hash(vision_frame.tobytes())
|
||||
vision_hash = create_hash(vision_frame.data)
|
||||
|
||||
if FACE_STORE.get(vision_hash):
|
||||
return FACE_STORE.get(vision_hash).get('faces')
|
||||
@@ -21,7 +21,7 @@ def get_faces(vision_frame : VisionFrame) -> Optional[List[Face]]:
|
||||
|
||||
def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None:
|
||||
if numpy.any(vision_frame):
|
||||
vision_hash = create_hash(vision_frame.tobytes())
|
||||
vision_hash = create_hash(vision_frame.data)
|
||||
FACE_STORE.setdefault(vision_hash,
|
||||
{
|
||||
'lock': threading.Lock()
|
||||
@@ -30,7 +30,7 @@ def set_faces(vision_frame : VisionFrame, faces : List[Face]) -> None:
|
||||
|
||||
def resolve_lock(vision_frame : VisionFrame) -> threading.Lock:
|
||||
if numpy.any(vision_frame):
|
||||
vision_hash = create_hash(vision_frame.tobytes())
|
||||
vision_hash = create_hash(vision_frame.data)
|
||||
return FACE_STORE.setdefault(vision_hash,
|
||||
{
|
||||
'lock': threading.Lock()
|
||||
|
||||
@@ -106,7 +106,7 @@ def start(webcam_device_id : int, webcam_mode : WebcamMode, webcam_resolution :
|
||||
yield capture_vision_frame
|
||||
if webcam_mode in [ 'udp', 'v4l2' ]:
|
||||
try:
|
||||
stream.stdin.write(capture_vision_frame.tobytes())
|
||||
stream.stdin.write(capture_vision_frame.data)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ def get_writer(video_path : str, temp_video_fps : Fps, temp_video_resolution : R
|
||||
|
||||
|
||||
def write_video_frame(video_writer : VideoWriter, vision_frame : VisionFrame) -> None:
|
||||
video_writer.get('process').stdin.write(vision_frame.tobytes())
|
||||
video_writer.get('process').stdin.write(vision_frame.data)
|
||||
|
||||
|
||||
def close_video_writer(video_writer : VideoWriter) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user