Spanicin commited on
Commit
6b00f63
·
verified ·
1 Parent(s): a199b1a

Update app.py

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