Move process time to the correct place

This commit is contained in:
henryruhs 2023-05-30 01:28:16 +02:00 committed by Somdev Sangwan
parent d7f72f7c5a
commit b9d20c0bff
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,4 @@
import os import os
import time
import cv2 import cv2
import insightface import insightface
import core.globals import core.globals
@ -14,7 +12,6 @@ else:
def process_video(source_img, frame_paths): def process_video(source_img, frame_paths):
start_time = time.time()
source_face = get_face(cv2.imread(source_img)) source_face = get_face(cv2.imread(source_img))
for frame_path in frame_paths: for frame_path in frame_paths:
frame = cv2.imread(frame_path) frame = cv2.imread(frame_path)
@ -29,9 +26,6 @@ def process_video(source_img, frame_paths):
except Exception as e: except Exception as e:
print('E', end='', flush=True) print('E', end='', flush=True)
pass 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): def process_img(source_img, target_path):

14
run.py
View File

@ -3,12 +3,15 @@
<<<<<<< HEAD <<<<<<< HEAD
import sys import sys
import time import time
<<<<<<< HEAD
======= =======
>>>>>>> 54f800d (Add GPU support, Quit on missing model, Remove globals (sorry)) >>>>>>> 54f800d (Add GPU support, Quit on missing model, Remove globals (sorry))
======= =======
import sys import sys
>>>>>>> dc0653a (Restore globals, add process time for better comparison) >>>>>>> dc0653a (Restore globals, add process time for better comparison)
=======
>>>>>>> 2b14613 (Move process time to the correct place)
import torch import torch
import shutil import shutil
import core.globals import core.globals
@ -61,8 +64,13 @@ def start_processing():
start_time = time.time() start_time = time.time()
if args['gpu']: if args['gpu']:
process_video(args['source_img'], args["frame_paths"]) process_video(args['source_img'], args["frame_paths"])
<<<<<<< HEAD
end_time = time.time() end_time = time.time()
print(flush=True) print(flush=True)
=======
print(flush=True)
end_time = time.time()
>>>>>>> 2b14613 (Move process time to the correct place)
print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True) print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True)
return return
frame_paths = args["frame_paths"] frame_paths = args["frame_paths"]
@ -75,6 +83,7 @@ def start_processing():
p.get() p.get()
pool.close() pool.close()
pool.join() pool.join()
<<<<<<< HEAD
end_time = time.time() end_time = time.time()
print(flush=True) print(flush=True)
print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True) print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True)
@ -108,6 +117,11 @@ def preview_video(video_path):
img_label.pack() img_label.pack()
cap.release() cap.release()
=======
print(flush=True)
end_time = time.time()
print(f"Processing time: {end_time - start_time:.2f} seconds", flush=True)
>>>>>>> 2b14613 (Move process time to the correct place)
def select_face(): def select_face():