- resolved conflicts with main branch

This commit is contained in:
chris 2023-05-31 17:03:49 -04:00
parent 6a410e8f84
commit d492cd68dc

View File

@ -3,7 +3,7 @@ from tqdm import tqdm
import cv2 import cv2
import insightface import insightface
import core.globals import core.globals
from core.analyser import get_face from core.analyser import get_face, get_all_faces
FACE_SWAPPER = None FACE_SWAPPER = None
@ -21,14 +21,29 @@ def process_video(source_img, frame_paths):
with tqdm(total=len(frame_paths), desc="Processing", unit="frame", dynamic_ncols=True, bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]') as progress: with tqdm(total=len(frame_paths), desc="Processing", unit="frame", dynamic_ncols=True, bar_format='{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}{postfix}]') as progress:
for frame_path in frame_paths: for frame_path in frame_paths:
frame = cv2.imread(frame_path) frame = cv2.imread(frame_path)
swapper = get_face_swapper()
try: try:
face = get_face(frame) if core.globals.all_faces:
if face: all_faces = get_all_faces(frame)
result = get_face_swapper().get(frame, face, source_face, paste_back=True) result = frame
if len(all_faces) > 0:
for singleFace in all_faces:
if singleFace:
result = swapper.get(result, singleFace, source_face, paste_back=True)
progress.set_postfix(status='.', refresh=True)
else:
progress.set_postfix(status='S', refresh=True)
else:
progress.set_postfix(status='S', refresh=True)
cv2.imwrite(frame_path, result) cv2.imwrite(frame_path, result)
progress.set_postfix(status='.', refresh=True)
else: else:
progress.set_postfix(status='S', refresh=True) face = get_face(frame)
if face:
result = swapper.get(frame, face, source_face, paste_back=True)
cv2.imwrite(frame_path, result)
progress.set_postfix(status='.', refresh=True)
else:
progress.set_postfix(status='S', refresh=True)
except Exception: except Exception:
progress.set_postfix(status='E', refresh=True) progress.set_postfix(status='E', refresh=True)
pass pass