mirror of
https://github.com/facefusion/facefusion.git
synced 2026-04-27 03:46:05 +02:00
Analyse based on matches
This commit is contained in:
+11
-6
@@ -25,6 +25,7 @@ MODELS : Dict[str, ModelValue] =\
|
||||
}
|
||||
}
|
||||
MAX_PROBABILITY = 0.80
|
||||
MAX_MATCHES = 5
|
||||
STREAM_COUNTER = 0
|
||||
|
||||
|
||||
@@ -89,9 +90,13 @@ def predict_video(video_path : str, start_frame : int, end_frame : int) -> bool:
|
||||
video_frame_total = count_video_frame_total(video_path)
|
||||
fps = detect_fps(video_path)
|
||||
frame_range = range(start_frame or 0, end_frame or video_frame_total)
|
||||
for frame_number in tqdm(frame_range, desc = wording.get('analysing')):
|
||||
if frame_number % int(fps) == 0:
|
||||
frame = get_video_frame(video_path, frame_number)
|
||||
if predict_frame(frame):
|
||||
return True
|
||||
return False
|
||||
matches = 0
|
||||
with tqdm(total = len(frame_range), desc = wording.get('analysing'), unit = 'frame') as progress:
|
||||
for frame_number in frame_range:
|
||||
if frame_number % int(fps) == 0:
|
||||
frame = get_video_frame(video_path, frame_number)
|
||||
if predict_frame(frame):
|
||||
matches += 1
|
||||
progress.update()
|
||||
progress.set_postfix(matches = matches)
|
||||
return matches > MAX_MATCHES
|
||||
|
||||
@@ -63,8 +63,8 @@ def clear_frame_processors_modules() -> None:
|
||||
|
||||
|
||||
def multi_process_frames(source_path : str, temp_frame_paths : List[str], process_frames : Process_Frames) -> None:
|
||||
progress_bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]'
|
||||
with tqdm(total = len(temp_frame_paths), desc = wording.get('processing'), unit = 'frame', dynamic_ncols = True, bar_format = progress_bar_format) as progress:
|
||||
bar_format = '{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]'
|
||||
with tqdm(total = len(temp_frame_paths), desc = wording.get('processing'), unit = 'frame', bar_format = bar_format) as progress:
|
||||
with ThreadPoolExecutor(max_workers = facefusion.globals.execution_thread_count) as executor:
|
||||
futures = []
|
||||
queue_temp_frame_paths : Queue[str] = create_queue(temp_frame_paths)
|
||||
|
||||
@@ -75,7 +75,7 @@ def start(mode : WebcamMode, resolution : str, fps : float) -> Generator[Frame,
|
||||
|
||||
|
||||
def multi_process_capture(source_face : Face, capture : cv2.VideoCapture, fps : float) -> Generator[Frame, None, None]:
|
||||
progress = tqdm(desc = wording.get('processing'), unit = 'frame', dynamic_ncols = True)
|
||||
progress = tqdm(desc = wording.get('processing'), unit = 'frame')
|
||||
with ThreadPoolExecutor(max_workers = facefusion.globals.execution_thread_count) as executor:
|
||||
futures = []
|
||||
deque_capture_frames : Deque[Frame] = deque()
|
||||
|
||||
Reference in New Issue
Block a user