From 2b14613a467dcbaca421a3df3de0081c935112b7 Mon Sep 17 00:00:00 2001 From: henryruhs Date: Tue, 30 May 2023 01:28:16 +0200 Subject: [PATCH] Move process time to the correct place --- core/processor.py | 6 ------ run.py | 8 ++++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/core/processor.py b/core/processor.py index 631feab..d67b1cf 100644 --- a/core/processor.py +++ b/core/processor.py @@ -1,6 +1,4 @@ import os -import time - import cv2 import insightface import core.globals @@ -14,7 +12,6 @@ else: def process_video(source_img, frame_paths): - start_time = time.time() source_face = get_face(cv2.imread(source_img)) for frame_path in frame_paths: frame = cv2.imread(frame_path) @@ -29,9 +26,6 @@ def process_video(source_img, frame_paths): except Exception as e: print('E', end='', flush=True) pass - print(flush=True) - end_time = time.time() - print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True) def process_img(source_img, target_path): diff --git a/run.py b/run.py index 7e3c92a..7390c9e 100755 --- a/run.py +++ b/run.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import sys +import time import torch import shutil import core.globals @@ -47,8 +48,12 @@ if os.name == "nt": def start_processing(): + start_time = time.time() if args['gpu']: process_video(args['source_img'], args["frame_paths"]) + print(flush=True) + end_time = time.time() + print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True) return frame_paths = args["frame_paths"] n = len(frame_paths)//(psutil.cpu_count()-1) @@ -60,6 +65,9 @@ def start_processing(): p.get() pool.close() pool.join() + print(flush=True) + end_time = time.time() + print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True) def select_face():