Spanicin commited on
Commit
3ae3408
1 Parent(s): eafd344

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -151,9 +151,12 @@ def main(args):
151
  print("Loading preprocessed data...")
152
  with open(preprocessed_data_path, "rb") as f:
153
  preprocessed_data = pickle.load(f)
154
- first_coeff_path = preprocessed_data["first_coeff_path"]
155
- crop_pic_path = preprocessed_data["crop_pic_path"]
156
- crop_info = preprocessed_data["crop_info"]
 
 
 
157
  print(f"Loaded existing preprocessed data from: {preprocessed_data_path}")
158
 
159
  else:
@@ -161,13 +164,17 @@ def main(args):
161
  first_coeff_path, crop_pic_path, crop_info = preprocess_model.generate(pic_path, first_frame_dir, args.preprocess, source_image_flag=True)
162
  first_coeff_new_path = os.path.join(fixed_temp_dir, os.path.basename(first_coeff_path))
163
  crop_pic_new_path = os.path.join(fixed_temp_dir, os.path.basename(crop_pic_path))
164
- crop_info_new_path = os.path.join(fixed_temp_dir, os.path.basename(crop_info))
165
  shutil.move(first_coeff_path, first_coeff_new_path)
166
  shutil.move(crop_pic_path, crop_pic_new_path)
167
- shutil.move(crop_info, crop_info_new_path)
 
 
 
168
  preprocessed_data = {"first_coeff_path": first_coeff_new_path,
169
  "crop_pic_path": crop_pic_new_path,
170
- "crop_info": crop_info_new_path}
 
171
 
172
  with open(preprocessed_data_path, "wb") as f:
173
  pickle.dump(preprocessed_data, f)
@@ -175,7 +182,7 @@ def main(args):
175
 
176
  print('first_coeff_path ',first_coeff_new_path)
177
  print('crop_pic_path ',crop_pic_new_path)
178
- print('crop_info ',crop_info_new_path)
179
 
180
  if first_coeff_path is None:
181
  print("Can't get the coeffs of the input")
 
151
  print("Loading preprocessed data...")
152
  with open(preprocessed_data_path, "rb") as f:
153
  preprocessed_data = pickle.load(f)
154
+ first_coeff_new_path = preprocessed_data["first_coeff_path"]
155
+ crop_pic_new_path = preprocessed_data["crop_pic_path"]
156
+ crop_info_path = preprocessed_data["crop_info_path"]
157
+ with open(crop_info_path, "rb") as f:
158
+ crop_info = pickle.load(f)
159
+
160
  print(f"Loaded existing preprocessed data from: {preprocessed_data_path}")
161
 
162
  else:
 
164
  first_coeff_path, crop_pic_path, crop_info = preprocess_model.generate(pic_path, first_frame_dir, args.preprocess, source_image_flag=True)
165
  first_coeff_new_path = os.path.join(fixed_temp_dir, os.path.basename(first_coeff_path))
166
  crop_pic_new_path = os.path.join(fixed_temp_dir, os.path.basename(crop_pic_path))
167
+ crop_info_new_path = os.path.join(fixed_temp_dir, "crop_info.pkl")
168
  shutil.move(first_coeff_path, first_coeff_new_path)
169
  shutil.move(crop_pic_path, crop_pic_new_path)
170
+
171
+ with open(crop_info_new_path, "wb") as f:
172
+ pickle.dump(crop_info, f)
173
+
174
  preprocessed_data = {"first_coeff_path": first_coeff_new_path,
175
  "crop_pic_path": crop_pic_new_path,
176
+ "crop_info_path": crop_info_new_path}
177
+
178
 
179
  with open(preprocessed_data_path, "wb") as f:
180
  pickle.dump(preprocessed_data, f)
 
182
 
183
  print('first_coeff_path ',first_coeff_new_path)
184
  print('crop_pic_path ',crop_pic_new_path)
185
+ print('crop_info ',crop_info)
186
 
187
  if first_coeff_path is None:
188
  print("Can't get the coeffs of the input")