Spanicin commited on
Commit
160df39
1 Parent(s): fa0311f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -99,10 +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, 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,16 +111,16 @@ def process_chunk(audio_chunk, args):
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(args.result_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)
@@ -270,7 +270,7 @@ def generate_video():
270
  try:
271
  if request.method == 'POST':
272
  # source_image = request.files['source_image']
273
- image_path = '/home/user/app/images/IMG_20241004_231233.jpg'
274
  source_image = Image.open(image_path)
275
  text_prompt = request.form['text_prompt']
276
 
@@ -335,8 +335,8 @@ def generate_video():
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
 
 
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, preprocessed_data):
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(args.result_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)
 
270
  try:
271
  if request.method == 'POST':
272
  # source_image = request.files['source_image']
273
+ image_path = '/home/user/app/images/marc_smile_enhanced.jpg'
274
  source_image = Image.open(image_path)
275
  text_prompt = request.form['text_prompt']
276
 
 
335
 
336
 
337
  try:
338
+ preprocessed_data = run_preprocessing(args)
339
+ base64_video, temp_file_path = process_chunk(driven_audio_path, args, preprocessed_data)
340
  final_video_path = app.config['final_video_path']
341
  print('final_video_path',final_video_path)
342