Analyse based on matches

This commit is contained in:
henryruhs
2023-10-17 17:25:39 +02:00
parent 220209bd3d
commit 0d7162ddf8
3 changed files with 14 additions and 9 deletions
+11 -6
View File
@@ -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
+2 -2
View File
@@ -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)
+1 -1
View File
@@ -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()