mirror of
https://github.com/facefusion/facefusion.git
synced 2026-07-31 06:17:27 +02:00
Next (#544)
* Modernize CI * Modernize CI * Modernize CI * Implement dynamic config (#518) * Implement dynamic config * Fix apply config * Move config to general * Move config to general * Move config to general * Add Windows installer * Add --open-browser * Add Windows installer part2 * Use non-commercial license for the installer * Fix create environment in installer * Fix openvino for installer * Fix conda for installer * Fix conda for installer, Remove python and pip as it is part of conda * Improve installer - guess the path * Fix CI * Add missing accept-source-agreements to installer * Install WinGet * Improve WinGet installation steps * Use absolute path for winget * More installer polishing * Add final page to installer, disable version check for Gradio * Remove finish page again * Use NEXT for metadata * Support for /S mode * Use winget-less approach * Improve Conda uninstall * Improve code using platform helpers (#529) * Update dependencies * Feat/fix windows unicode paths (#531) * Fix the Windows unicode path dilemma * Update dependencies * Fix the Windows unicode path dilemma part2 * Remove conda environment on uninstall * Fix uninstall command * Install apps for local user only * Add ultra sharp * Add clear reality * Update README and FUNDING * Update FUNDING.yml * Prevent preview of large videos in Gradio (#540) * Fix order * Refactor temporary file management, Use temporary file for image processing (#542) * Allow webm on target component * Reduce mosaic effect for frame processors * clear static faces on trim frame changes * Fix trim frame component * Downgrade openvino dependency * Prepare next release * Move get_short_path to filesystem, Add/Improve some testing * Prepare installer, Prevent infinite loop for sanitize_path_for_windows * Introduce execution device id * Introduce execution device id * Seems like device id can be a string * Seems like device id can be a string * Make Intel Arc work with OpenVINOExecution * Use latest Git * Update wording * Fix create_float_range * Update preview * Fix Git link
This commit is contained in:
+27
-14
@@ -4,9 +4,10 @@ import cv2
|
||||
import numpy
|
||||
from cv2.typing import Size
|
||||
|
||||
from facefusion.common_helper import is_windows
|
||||
from facefusion.typing import VisionFrame, Resolution, Fps
|
||||
from facefusion.choices import image_template_sizes, video_template_sizes
|
||||
from facefusion.filesystem import is_image, is_video
|
||||
from facefusion.filesystem import is_image, is_video, sanitize_path_for_windows
|
||||
|
||||
|
||||
@lru_cache(maxsize = 128)
|
||||
@@ -24,12 +25,16 @@ def read_static_images(image_paths : List[str]) -> Optional[List[VisionFrame]]:
|
||||
|
||||
def read_image(image_path : str) -> Optional[VisionFrame]:
|
||||
if is_image(image_path):
|
||||
if is_windows():
|
||||
image_path = sanitize_path_for_windows(image_path)
|
||||
return cv2.imread(image_path)
|
||||
return None
|
||||
|
||||
|
||||
def write_image(image_path : str, vision_frame : VisionFrame) -> bool:
|
||||
if image_path:
|
||||
if is_windows():
|
||||
image_path = sanitize_path_for_windows(image_path)
|
||||
return cv2.imwrite(image_path, vision_frame)
|
||||
return False
|
||||
|
||||
@@ -50,19 +55,6 @@ def restrict_image_resolution(image_path : str, resolution : Resolution) -> Reso
|
||||
return resolution
|
||||
|
||||
|
||||
def get_video_frame(video_path : str, frame_number : int = 0) -> Optional[VisionFrame]:
|
||||
if is_video(video_path):
|
||||
video_capture = cv2.VideoCapture(video_path)
|
||||
if video_capture.isOpened():
|
||||
frame_total = video_capture.get(cv2.CAP_PROP_FRAME_COUNT)
|
||||
video_capture.set(cv2.CAP_PROP_POS_FRAMES, min(frame_total, frame_number - 1))
|
||||
has_vision_frame, vision_frame = video_capture.read()
|
||||
video_capture.release()
|
||||
if has_vision_frame:
|
||||
return vision_frame
|
||||
return None
|
||||
|
||||
|
||||
def create_image_resolutions(resolution : Resolution) -> List[str]:
|
||||
resolutions = []
|
||||
temp_resolutions = []
|
||||
@@ -78,8 +70,25 @@ def create_image_resolutions(resolution : Resolution) -> List[str]:
|
||||
return resolutions
|
||||
|
||||
|
||||
def get_video_frame(video_path : str, frame_number : int = 0) -> Optional[VisionFrame]:
|
||||
if is_video(video_path):
|
||||
if is_windows():
|
||||
video_path = sanitize_path_for_windows(video_path)
|
||||
video_capture = cv2.VideoCapture(video_path)
|
||||
if video_capture.isOpened():
|
||||
frame_total = video_capture.get(cv2.CAP_PROP_FRAME_COUNT)
|
||||
video_capture.set(cv2.CAP_PROP_POS_FRAMES, min(frame_total, frame_number - 1))
|
||||
has_vision_frame, vision_frame = video_capture.read()
|
||||
video_capture.release()
|
||||
if has_vision_frame:
|
||||
return vision_frame
|
||||
return None
|
||||
|
||||
|
||||
def count_video_frame_total(video_path : str) -> int:
|
||||
if is_video(video_path):
|
||||
if is_windows():
|
||||
video_path = sanitize_path_for_windows(video_path)
|
||||
video_capture = cv2.VideoCapture(video_path)
|
||||
if video_capture.isOpened():
|
||||
video_frame_total = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))
|
||||
@@ -90,6 +99,8 @@ def count_video_frame_total(video_path : str) -> int:
|
||||
|
||||
def detect_video_fps(video_path : str) -> Optional[float]:
|
||||
if is_video(video_path):
|
||||
if is_windows():
|
||||
video_path = sanitize_path_for_windows(video_path)
|
||||
video_capture = cv2.VideoCapture(video_path)
|
||||
if video_capture.isOpened():
|
||||
video_fps = video_capture.get(cv2.CAP_PROP_FPS)
|
||||
@@ -108,6 +119,8 @@ def restrict_video_fps(video_path : str, fps : Fps) -> Fps:
|
||||
|
||||
def detect_video_resolution(video_path : str) -> Optional[Resolution]:
|
||||
if is_video(video_path):
|
||||
if is_windows():
|
||||
video_path = sanitize_path_for_windows(video_path)
|
||||
video_capture = cv2.VideoCapture(video_path)
|
||||
if video_capture.isOpened():
|
||||
width = video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)
|
||||
|
||||
Reference in New Issue
Block a user