diff --git a/applications/wyw2s_local_app.py b/applications/wyw2s_local_app.py index 38d2b0f859dc04f36f11e1d3b8baa96a27c4330a..91bd029a20b6a5f3d5f409af9b35c2543b17340a 100644 --- a/applications/wyw2s_local_app.py +++ b/applications/wyw2s_local_app.py @@ -22,10 +22,10 @@ import time from multiprocessing import Process from multiprocessing import Manager -import cv2 import numpy as np import random import time +import shutil # 加载模型组件库 from face_detect.yolo_v3_face import yolo_v3_face_model @@ -41,15 +41,28 @@ from utils.show_videos_thread import run_show from moviepy.editor import * -def main_wyw2s(cfg_file,video_path = None): +def main_wyw2s(video_path,cfg_file): config = parse_data_cfg(cfg_file) - face_detect_model = yolo_v3_face_model(conf_thres = 0.43) - face_verify_model = insight_face_model(threshold = 1.2) - face_multitask_model = FaceMuitiTask_Model() - face_euler_model = FaceAngle_Model() + print("\n/---------------------- main_wyw2s config ------------------------/\n") + for k_ in config.keys(): + print("{} : {}".format(k_,config[k_])) + print("\n/------------------------------------------------------------------------/\n") + + print("\n loading who you want 2 see local demo ...\n") + + face_detect_model = yolo_v3_face_model(conf_thres=float(config["detect_conf_thres"]),nms_thres=float(config["detect_nms_thres"]), + model_arch = config["detect_model_arch"],model_path = config["detect_model_path"],yolo_anchor_scale = float(config["yolo_anchor_scale"]), + img_size = float(config["detect_input_size"]), + ) + face_verify_model = insight_face_model(backbone_model_path =config["face_verify_backbone_path"] , + facebank_path = config["facebank_path"], + threshold = float(config["face_verify_threshold"])) + + face_multitask_model = FaceMuitiTask_Model(model_path = config["face_multitask_model_path"]) + face_euler_model = FaceAngle_Model(model_path = config["face_euler_model_path"]) print("\n/------------------------------------------------------------------------/\n") YouWantToSee = config["YouWantToSee"] @@ -74,7 +87,6 @@ def main_wyw2s(cfg_file,video_path = None): else: p_colors.append((random.randint(60,255),random.randint(70,255),random.randint(130,255))) - cap = cv2.VideoCapture(video_path) frame_count = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) @@ -88,7 +100,6 @@ def main_wyw2s(cfg_file,video_path = None): frame_idx = 0 Flag_Last,Flag_Now = False,False start_time = 0. - end_time = 0. YouWantToSee_time_list = [] while cap.isOpened(): @@ -124,7 +135,6 @@ def main_wyw2s(cfg_file,video_path = None): print(" ------ ") Flag_Now = False - else: face_map = np.zeros([112*3,112*3,3]).astype(np.uint8) face_map[:,:,0].fill(205) @@ -180,6 +190,10 @@ def main_wyw2s(cfg_file,video_path = None): print("\n ----->>> YouWantToSee_Time_list : \n") movie = VideoFileClip(video_path) video_s = "./clip_wyw2s/" + + if os.path.exists(video_s): #删除之前的文件夹 + shutil.rmtree(video_s) + if not os.path.exists(video_s): # 如果文件夹不存在 os.mkdir(video_s) # 生成文件夹 diff --git a/components/face_detect/yolo_v3_face.py b/components/face_detect/yolo_v3_face.py index c79eb3fc808a9d93bf51151db532bf6c3dd39805..ace09ab0522701559c67ae483785af313202cef9 100644 --- a/components/face_detect/yolo_v3_face.py +++ b/components/face_detect/yolo_v3_face.py @@ -10,9 +10,9 @@ import time import torch -from hand_detect.yolov3 import Yolov3, Yolov3Tiny -from hand_detect.utils.torch_utils import select_device -from hand_detect.acc_model import acc_model +from face_detect.yolov3 import Yolov3, Yolov3Tiny +from face_detect.utils.torch_utils import select_device +from face_detect.acc_model import acc_model import torch.backends.cudnn as cudnn import torch.nn.functional as F