Add a processer bar with remain time for CLI
This commit is contained in:
parent
38fb60efca
commit
cfd29513b4
@ -1,9 +1,10 @@
|
|||||||
import os
|
import os
|
||||||
|
from tqdm import tqdm
|
||||||
import cv2
|
import cv2
|
||||||
import insightface
|
import insightface
|
||||||
import core.globals
|
import core.globals
|
||||||
from core.config import get_face
|
from core.config import get_face
|
||||||
|
from tqdm import tqdm
|
||||||
|
|
||||||
FACE_SWAPPER = None
|
FACE_SWAPPER = None
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ def get_face_swapper():
|
|||||||
|
|
||||||
def process_video(source_img, frame_paths):
|
def process_video(source_img, frame_paths):
|
||||||
source_face = get_face(cv2.imread(source_img))
|
source_face = get_face(cv2.imread(source_img))
|
||||||
|
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 pbar:
|
||||||
for frame_path in frame_paths:
|
for frame_path in frame_paths:
|
||||||
frame = cv2.imread(frame_path)
|
frame = cv2.imread(frame_path)
|
||||||
try:
|
try:
|
||||||
@ -25,12 +27,13 @@ def process_video(source_img, frame_paths):
|
|||||||
if face:
|
if face:
|
||||||
result = get_face_swapper().get(frame, face, source_face, paste_back=True)
|
result = get_face_swapper().get(frame, face, source_face, paste_back=True)
|
||||||
cv2.imwrite(frame_path, result)
|
cv2.imwrite(frame_path, result)
|
||||||
print('.', end='', flush=True)
|
pbar.set_postfix(status='.', refresh=True)
|
||||||
else:
|
else:
|
||||||
print('S', end='', flush=True)
|
pbar.set_postfix(status='S', refresh=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
print('E', end='', flush=True)
|
pbar.set_postfix(status='E', refresh=True)
|
||||||
pass
|
pass
|
||||||
|
pbar.update(1)
|
||||||
|
|
||||||
|
|
||||||
def process_img(source_img, target_path, output_file):
|
def process_img(source_img, target_path, output_file):
|
||||||
|
Loading…
Reference in New Issue
Block a user