Commit
•
d36d8c3
1
Parent(s):
d816efb
Update app.py
Browse files
app.py
CHANGED
@@ -213,22 +213,36 @@ class AnimateController:
|
|
213 |
self.savedir_sample, f"{sample_idx}.mp4")
|
214 |
save_videos_grid(sample, save_sample_path)
|
215 |
|
216 |
-
sample_config = {
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
}
|
227 |
-
json_str = json.dumps(sample_config, indent=4)
|
228 |
-
with open(os.path.join(self.savedir, "logs.json"), "a") as f:
|
229 |
-
|
230 |
-
|
231 |
-
return gr.Video.update(value=save_sample_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
|
233 |
|
234 |
controller = AnimateController()
|
@@ -332,8 +346,7 @@ def ui():
|
|
332 |
generate_button = gr.Button(
|
333 |
value="Generate", variant='primary')
|
334 |
|
335 |
-
|
336 |
-
label="Generated Animation", interactive=False)
|
337 |
|
338 |
generate_button.click(
|
339 |
fn=controller.animate,
|
@@ -351,7 +364,7 @@ def ui():
|
|
351 |
cfg_scale_slider,
|
352 |
seed_textbox,
|
353 |
],
|
354 |
-
outputs=[
|
355 |
)
|
356 |
|
357 |
return demo
|
|
|
213 |
self.savedir_sample, f"{sample_idx}.mp4")
|
214 |
save_videos_grid(sample, save_sample_path)
|
215 |
|
216 |
+
# sample_config = {
|
217 |
+
# "prompt": prompt_textbox,
|
218 |
+
# "n_prompt": negative_prompt_textbox,
|
219 |
+
# "sampler": sampler_dropdown,
|
220 |
+
# "num_inference_steps": sample_step_slider,
|
221 |
+
# "guidance_scale": cfg_scale_slider,
|
222 |
+
# "width": width_slider,
|
223 |
+
# "height": height_slider,
|
224 |
+
# "video_length": length_slider,
|
225 |
+
# "seed": seed
|
226 |
+
# }
|
227 |
+
# json_str = json.dumps(sample_config, indent=4)
|
228 |
+
# with open(os.path.join(self.savedir, "logs.json"), "a") as f:
|
229 |
+
# f.write(json_str)
|
230 |
+
# f.write("\n\n")
|
231 |
+
# return gr.Video.update(value=save_sample_path)
|
232 |
+
|
233 |
+
|
234 |
+
# Read the content of the video file and encode it to base64
|
235 |
+
with open(save_sample_path, "rb") as video_file:
|
236 |
+
video_base64 = base64.b64encode(video_file.read()).decode('utf-8')
|
237 |
+
|
238 |
+
# Prepend the appropriate data URI header with MIME type
|
239 |
+
video_data_uri = 'data:video/mp4;base64,' + video_base64
|
240 |
+
|
241 |
+
# clean-up (otherwise there is a risk of "ghosting", eg. someone seeing the previous generated video",
|
242 |
+
# of one of the steps go wrong)
|
243 |
+
os.remove(video_path)
|
244 |
+
|
245 |
+
return video_data_uri
|
246 |
|
247 |
|
248 |
controller = AnimateController()
|
|
|
346 |
generate_button = gr.Button(
|
347 |
value="Generate", variant='primary')
|
348 |
|
349 |
+
result_video_base_64 = gr.Text()
|
|
|
350 |
|
351 |
generate_button.click(
|
352 |
fn=controller.animate,
|
|
|
364 |
cfg_scale_slider,
|
365 |
seed_textbox,
|
366 |
],
|
367 |
+
outputs=[result_video_base64]
|
368 |
)
|
369 |
|
370 |
return demo
|