Spanicin commited on
Commit
7966754
·
verified ·
1 Parent(s): 3f5143c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -99,9 +99,10 @@ audio2exp_yaml_path = os.path.join(current_root_path, 'src', 'config', 'auido2ex
99
  free_view_checkpoint = os.path.join(current_root_path, 'checkpoints', 'facevid2vid_00189-model.pth.tar')
100
 
101
  # Function for running the actual task (using preprocessed data)
102
- def process_chunk(audio_chunk, preprocessed_data, args):
103
  print("Entered Process Chunk Function")
104
  global audio2pose_checkpoint, audio2pose_yaml_path, audio2exp_checkpoint, audio2exp_yaml_path, wav2lip_checkpoint
 
105
  global free_view_checkpoint
106
  if args.preprocess == 'full':
107
  mapping_checkpoint = os.path.join(current_root_path, 'checkpoints', 'mapping_00109-model.pth.tar')
@@ -110,11 +111,16 @@ def process_chunk(audio_chunk, preprocessed_data, args):
110
  mapping_checkpoint = os.path.join(current_root_path, 'checkpoints', 'mapping_00229-model.pth.tar')
111
  facerender_yaml_path = os.path.join(current_root_path, 'src', 'config', 'facerender.yaml')
112
 
113
- first_coeff_path = preprocessed_data["first_coeff_path"]
114
- crop_pic_path = preprocessed_data["crop_pic_path"]
115
- crop_info_path = "/home/user/app/preprocess_data/crop_info.json"
116
- with open(crop_info_path , "rb") as f:
117
- crop_info = json.load(f)
 
 
 
 
 
118
 
119
  print(f"Loaded existing preprocessed data")
120
  print("first_coeff_path",first_coeff_path)
@@ -329,8 +335,8 @@ def generate_video():
329
 
330
 
331
  try:
332
- preprocessed_data = run_preprocessing(args)
333
- base64_video, temp_file_path = process_chunk(driven_audio_path, preprocessed_data, args)
334
  final_video_path = app.config['final_video_path']
335
  print('final_video_path',final_video_path)
336
 
 
99
  free_view_checkpoint = os.path.join(current_root_path, 'checkpoints', 'facevid2vid_00189-model.pth.tar')
100
 
101
  # Function for running the actual task (using preprocessed data)
102
+ def process_chunk(audio_chunk, args):
103
  print("Entered Process Chunk Function")
104
  global audio2pose_checkpoint, audio2pose_yaml_path, audio2exp_checkpoint, audio2exp_yaml_path, wav2lip_checkpoint
105
+ global path_of_lm_croper, path_of_net_recon_model, dir_of_BFM_fitting
106
  global free_view_checkpoint
107
  if args.preprocess == 'full':
108
  mapping_checkpoint = os.path.join(current_root_path, 'checkpoints', 'mapping_00109-model.pth.tar')
 
111
  mapping_checkpoint = os.path.join(current_root_path, 'checkpoints', 'mapping_00229-model.pth.tar')
112
  facerender_yaml_path = os.path.join(current_root_path, 'src', 'config', 'facerender.yaml')
113
 
114
+ # first_coeff_path = preprocessed_data["first_coeff_path"]
115
+ # crop_pic_path = preprocessed_data["crop_pic_path"]
116
+ # crop_info_path = "/home/user/app/preprocess_data/crop_info.json"
117
+ # with open(crop_info_path , "rb") as f:
118
+ # crop_info = json.load(f)
119
+
120
+ first_frame_dir = os.path.join(save_dir, 'first_frame_dir')
121
+ os.makedirs(first_frame_dir, exist_ok=True)
122
+ preprocess_model = CropAndExtract(path_of_lm_croper, path_of_net_recon_model, dir_of_BFM_fitting, args.device)
123
+ first_coeff_path, crop_pic_path, crop_info = preprocess_model.generate(args.source_image, first_frame_dir, args.preprocess, source_image_flag=True)
124
 
125
  print(f"Loaded existing preprocessed data")
126
  print("first_coeff_path",first_coeff_path)
 
335
 
336
 
337
  try:
338
+ # preprocessed_data = run_preprocessing(args)
339
+ base64_video, temp_file_path = process_chunk(driven_audio_path, args)
340
  final_video_path = app.config['final_video_path']
341
  print('final_video_path',final_video_path)
342