handle no face cases

This commit is contained in:
Somdev Sangwan 2023-05-29 17:50:42 +05:30 committed by GitHub
parent b6efc0bed8
commit e6ae4cf767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
run.py
View File

@ -8,9 +8,11 @@ from tkinter import filedialog
from tkinter.filedialog import asksaveasfilename from tkinter.filedialog import asksaveasfilename
from core.processor import process_video, process_img from core.processor import process_video, process_img
from core.utils import is_img, detect_fps, set_fps, create_video, add_audio, extract_frames from core.utils import is_img, detect_fps, set_fps, create_video, add_audio, extract_frames
from core.config import get_face
import webbrowser import webbrowser
import psutil import psutil
import shutil import shutil
import cv2
pool = None pool = None
args = {} args = {}
@ -67,6 +69,10 @@ def start():
global pool global pool
pool = mp.Pool(psutil.cpu_count()-1) pool = mp.Pool(psutil.cpu_count()-1)
target_path = args['target_path'] target_path = args['target_path']
test_face = get_face(cv2.imread(args['source_img']))
if not test_face:
print("\n[WARNING] No face detected in source image. Please try with another one.\n")
return
if is_img(target_path): if is_img(target_path):
process_img(args['source_img'], target_path) process_img(args['source_img'], target_path)
return return