Spaces:
Configuration error
Configuration error
Download facefusion/face_cache.py from Himankpro/FaceFusion: direct link, hf CLI and curl.
- Browser
- Download file 679 Bytes
-
https://huggingface.co/spaces/Himankpro/FaceFusion/resolve/main/facefusion/face_cache.py
- Command line
-
hf download hf://spaces/Himankpro/FaceFusion/facefusion/face_cache.py
-
curl -L -o face_cache.py https://huggingface.co/spaces/Himankpro/FaceFusion/resolve/main/facefusion/face_cache.py
679 Bytes
| from typing import Optional, List, Dict | |
| import hashlib | |
| from facefusion.typing import Frame, Face | |
| FACES_CACHE : Dict[str, List[Face]] = {} | |
| def get_faces_cache(frame : Frame) -> Optional[List[Face]]: | |
| frame_hash = create_frame_hash(frame) | |
| if frame_hash in FACES_CACHE: | |
| return FACES_CACHE[frame_hash] | |
| return None | |
| def set_faces_cache(frame : Frame, faces : List[Face]) -> None: | |
| frame_hash = create_frame_hash(frame) | |
| if frame_hash: | |
| FACES_CACHE[frame_hash] = faces | |
| def clear_faces_cache() -> None: | |
| global FACES_CACHE | |
| FACES_CACHE = {} | |
| def create_frame_hash(frame : Frame) -> Optional[str]: | |
| return hashlib.sha1(frame.tobytes()).hexdigest() if frame.any() else None | |