hanstyle commited on
Commit
b95fede
·
1 Parent(s): c78fb47

Update inference.py

Browse files
Files changed (1) hide show
  1. inference.py +7 -4
inference.py CHANGED
@@ -53,6 +53,9 @@ parser.add_argument('--nosmooth', default=False, action='store_true',
53
  args = parser.parse_args()
54
  args.img_size = 96
55
 
 
 
 
56
  if os.path.isfile(args.face) and args.face.split('.')[1] in ['jpg', 'png', 'jpeg']:
57
  args.static = True
58
 
@@ -216,10 +219,10 @@ def main():
216
 
217
  if not args.audio.endswith('.wav'):
218
  print('Extracting raw audio...')
219
- command = 'ffmpeg -y -i {} -strict -2 {}'.format(args.audio, './temp/temp.wav')
220
 
221
  subprocess.call(command, shell=True)
222
- args.audio = './temp/temp.wav'
223
 
224
  wav = audio.load_wav(args.audio, 16000)
225
  mel = audio.melspectrogram(wav)
@@ -253,7 +256,7 @@ def main():
253
  print ("Model loaded")
254
 
255
  frame_h, frame_w = full_frames[0].shape[:-1]
256
- out = cv2.VideoWriter('./temp/result.avi',
257
  cv2.VideoWriter_fourcc(*'DIVX'), fps, (frame_w, frame_h))
258
 
259
  img_batch = torch.FloatTensor(np.transpose(img_batch, (0, 3, 1, 2))).to(device)
@@ -273,7 +276,7 @@ def main():
273
 
274
  out.release()
275
 
276
- command = 'ffmpeg -y -i {} -i {} -strict -2 -q:v 1 {}'.format(args.audio, './temp/result.avi', args.outfile)
277
  subprocess.call(command, shell=platform.system() != 'Windows')
278
 
279
  if __name__ == '__main__':
 
53
  args = parser.parse_args()
54
  args.img_size = 96
55
 
56
+
57
+ temppath = os.path.join(os.path.dirname(__file__), "temp")
58
+
59
  if os.path.isfile(args.face) and args.face.split('.')[1] in ['jpg', 'png', 'jpeg']:
60
  args.static = True
61
 
 
219
 
220
  if not args.audio.endswith('.wav'):
221
  print('Extracting raw audio...')
222
+ command = 'ffmpeg -y -i {} -strict -2 {}'.format(args.audio, f'{temppath}/temp.wav')
223
 
224
  subprocess.call(command, shell=True)
225
+ args.audio = f'{temppath}/temp.wav'
226
 
227
  wav = audio.load_wav(args.audio, 16000)
228
  mel = audio.melspectrogram(wav)
 
256
  print ("Model loaded")
257
 
258
  frame_h, frame_w = full_frames[0].shape[:-1]
259
+ out = cv2.VideoWriter(f'{temppath}/result.avi',
260
  cv2.VideoWriter_fourcc(*'DIVX'), fps, (frame_w, frame_h))
261
 
262
  img_batch = torch.FloatTensor(np.transpose(img_batch, (0, 3, 1, 2))).to(device)
 
276
 
277
  out.release()
278
 
279
+ command = 'ffmpeg -y -i {} -i {} -strict -2 -q:v 1 {}'.format(args.audio, f'{temppath}/result.avi', args.outfile)
280
  subprocess.call(command, shell=platform.system() != 'Windows')
281
 
282
  if __name__ == '__main__':