goryhon commited on
Commit
8429e13
·
verified ·
1 Parent(s): 87bd889

Update web-demos/hugging_face/app.py

Browse files
Files changed (1) hide show
  1. web-demos/hugging_face/app.py +8 -1
web-demos/hugging_face/app.py CHANGED
@@ -335,9 +335,16 @@ def generate_video_from_frames(frames, output_path, fps=30):
335
  output_path (str): The path to save the generated video.
336
  fps (int, optional): The frame rate of the output video. Defaults to 30.
337
  """
338
- frames = torch.from_numpy(np.asarray(frames))
 
 
 
 
 
339
  if not os.path.exists(os.path.dirname(output_path)):
340
  os.makedirs(os.path.dirname(output_path))
 
 
341
  torchvision.io.write_video(output_path, frames, fps=fps, video_codec="libx264")
342
  return output_path
343
 
 
335
  output_path (str): The path to save the generated video.
336
  fps (int, optional): The frame rate of the output video. Defaults to 30.
337
  """
338
+ # Приведение fps к обычному float (из np.float64, если нужно)
339
+ fps = float(fps)
340
+
341
+ frames = torch.from_numpy(np.asarray(frames)) # shape: (T, H, W, C)
342
+
343
+ # Убедимся, что директория существует
344
  if not os.path.exists(os.path.dirname(output_path)):
345
  os.makedirs(os.path.dirname(output_path))
346
+
347
+ # Пишем видео
348
  torchvision.io.write_video(output_path, frames, fps=fps, video_codec="libx264")
349
  return output_path
350