Beispiel #1
0
 def __init__(self, dir_list, state=None):
     self.dir_list = dir_list
     self.input_A_path = get_dir(dir_list, 't')
     self.input_B_path = get_dir(dir_list, 'r')
     self.model_path = get_dir(dir_list, 'm')
     self.output_path = dir_list[3]
     self.state = state
Beispiel #2
0
 def __init__(self, dir_list, state=None):
     self.input_A_path = get_dir(dir_list, 't')
     self.input_B_path = get_dir(dir_list, 'r')
     self.model_path = get_dir(dir_list, 'm')
     self.state = state
     self.GPU_check()
     keras.backend.clear_session()
     self.process()
Beispiel #3
0
    def __init__(self, dir_list, state):
        try:
            os.mkdir('ImageCache')
        except:
            import shutil
            shutil.rmtree('ImageCache')
            os.mkdir('ImageCache')

        self.exit_flag = False
        self.state = state
        if not self.state.empty():
            if self.state.get() == 'stop_pre':
                self.exit_flag = True
        for temp in ['t', 'r']:
            if self.exit_flag:
                break
            if temp == 't':
                print('-----------------开始提取目标视频帧------------------')
            else:
                print('-----------------开始提取素材视频帧------------------')
            self.input_video_name = get_dir(dir_list, temp)
            if temp == 't':
                self.v2f(dir_list[0])
            elif temp == 'r':
                self.v2f(dir_list[1])
Beispiel #4
0
 def dir_check(self, dir):
     Ready_flag = True
     if dir == 'm':
         if not os.path.exists(utils.get_dir(
                 self.path_list(), 'e_t')) or not os.path.exists(
                     utils.get_dir(self.path_list(), 'e_r')):
             Ready_flag = False
             print('未能成功读取面部识别文件,请进行预处理')
     elif dir == 'c':
         if not os.path.exists(utils.get_dir(
                 self.path_list(), 't')) or not os.path.exists(
                     utils.get_dir(self.path_list(), 'r')):
             Ready_flag = False
             print('未能成功读取预处理文件,请进行预处理')
         if not os.path.exists(utils.get_dir(self.path_list(), 'm')):
             Ready_flag = False
             print('未能成功读取训练模型文件,请进行训练')
     return Ready_flag
Beispiel #5
0
 def convert_process(self, state):
     con = convert.ConvertImage(self.path_list(), state)
     con.process()
     if state.empty():
         merge.MergeImage(self, state)
     elif not state.empty():
         if state.get() == 'stop_con':
             path = utils.get_dir(self, 't') + '_convert'
             time.sleep(1)
             if os.path.exists(path):
                 import shutil
                 shutil.rmtree(path)
Beispiel #6
0
 def __init__(self, dir_list, state=None, fps=30):
     self.state = state
     self.output_path = dir_list[3]
     self.img_path = get_dir(dir_list, 't')
     self.raw_path = get_dir(dir_list, 'r')
     self.exit_flag = False
     self.fps = fps
     try:
         if self.state is not None:
             if not self.state.empty():
                 if self.state.get() == 'stop_con':
                     self.exit_flag = True
                     print('取消合成,正在清理缓存文件。')
                     return
         self.process()
     finally:
         if not self.exit_flag:
             print('合成完成')
         elif self.exit_flag:
             path = self.img_path + '_convert'
             if os.path.exists(path):
                 import shutil
                 shutil.rmtree(path)
Beispiel #7
0
    def process(self, state):
        self.exit_flag = False
        self.state = state
        if not self.state.empty():
            if self.state.get() == 'stop_pre':
                self.exit_flag = True
        extractor = Extract_Align.Extract()
        for temp in ['t','r']:
            if self.exit_flag:
                break
            if temp == 't':
                print('---------------开始提取目标视频面部区域---------------')
            else:
                print('---------------开始提取素材视频面部区域---------------')

            output_image_filename = get_dir(self.dir_list, temp)
            filenames = os.listdir(output_image_filename)
            Path_Manager.make_path(output_image_filename+'\\Extracted_image')
            index = 0
            for filename in filenames:
                if self.exit_flag:
                    break
                if not self.state.empty():
                    if self.state.get() == 'stop_pre':
                        self.exit_flag = True
                if filename == 'Extracted_image':
                    continue
                index += 1
                image = cv2.imread(output_image_filename + '\\' + filename)

                for idx, face in self.get_faces(image):
                    if index %50 == 49:
                        print('面部提取已完成%i帧'%(index + 1))
                    resized_image = extractor.extract(image, face, 256)
                    cv2.imwrite(output_image_filename + '\\Extracted_image\\' + 'Extracted_image_' + str(index) + '.jpg',
                                resized_image)
        queue_clear(self.state)
        print('-------------------面部区域提取结束------------------')