RamAnanth1 commited on
Commit
1bfbba7
β€’
1 Parent(s): 3499e0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -94,13 +94,25 @@ def sample_text2video(model, prompt, n_samples, batch_size,
94
  assert(all_videos.shape[0] >= n_samples)
95
  return all_videos
96
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  def get_video(prompt):
99
  samples = sample_text2video(model, prompt, n_samples = 1, batch_size = 1,
100
  sampler=ddim_sampler,
101
  )
102
-
103
- return samples[0]
104
 
105
  prompt_inp = gr.Textbox(label = "Prompt")
106
  iface = gr.Interface(fn=get_video, inputs=[prompt_inp], outputs="text")
 
94
  assert(all_videos.shape[0] >= n_samples)
95
  return all_videos
96
 
97
+ def save_results(videos,
98
+ save_name="results", save_fps=8, save_mp4=True,
99
+ save_npz=False, save_mp4_sheet=False, save_jpg=False
100
+ ):
101
+
102
+ save_subdir = os.path.join("videos")
103
+ os.makedirs(save_subdir, exist_ok=True)
104
+ for i in range(videos.shape[0]):
105
+ npz_to_video_grid(videos[i:i+1,...],
106
+ os.path.join(save_subdir, f"{save_name}_{i:03d}.mp4"),
107
+ fps=save_fps)
108
+ return 'Successfully saved videos in ' + save_subdir
109
 
110
  def get_video(prompt):
111
  samples = sample_text2video(model, prompt, n_samples = 1, batch_size = 1,
112
  sampler=ddim_sampler,
113
  )
114
+
115
+ return save_results(samples)
116
 
117
  prompt_inp = gr.Textbox(label = "Prompt")
118
  iface = gr.Interface(fn=get_video, inputs=[prompt_inp], outputs="text")