tracyorcaleb
commited on
Commit
•
580dcd1
1
Parent(s):
fa08cd8
Add static video
Browse files- app.py +9 -6
- out.jpg +0 -0
- video_out.mp4 +0 -0
app.py
CHANGED
@@ -19,13 +19,15 @@ def add_static_image_to_audio(image, audio):
|
|
19 |
# create the image clip object
|
20 |
image_clip = ImageClip(image)
|
21 |
# use set_audio method from image clip to combine the audio with the image
|
22 |
-
video_clip = image_clip.set_audio(
|
23 |
# specify the duration of the new clip to be the duration of the audio clip
|
24 |
-
video_clip.duration =
|
25 |
# set the FPS to 1
|
26 |
video_clip.fps = 1
|
27 |
# write the resuling video clip
|
28 |
-
|
|
|
|
|
29 |
|
30 |
def get_stable_diffusion_image(prompt):
|
31 |
model_id = "CompVis/stable-diffusion-v1-4"
|
@@ -34,9 +36,10 @@ def get_stable_diffusion_image(prompt):
|
|
34 |
pipe = pipe.to(device)
|
35 |
with autocast("cuda"):
|
36 |
image = pipe(prompt, guidance_scale=7.5)["sample"][0]
|
37 |
-
|
38 |
-
|
|
|
39 |
|
40 |
|
41 |
-
iface = gr.Interface(fn=process_inputs, inputs=["text", "
|
42 |
iface.launch()
|
|
|
19 |
# create the image clip object
|
20 |
image_clip = ImageClip(image)
|
21 |
# use set_audio method from image clip to combine the audio with the image
|
22 |
+
video_clip = image_clip.set_audio(audio_clip)
|
23 |
# specify the duration of the new clip to be the duration of the audio clip
|
24 |
+
video_clip.duration = audio_clip.duration
|
25 |
# set the FPS to 1
|
26 |
video_clip.fps = 1
|
27 |
# write the resuling video clip
|
28 |
+
path = "video_out.mp4"
|
29 |
+
video_clip.write_videofile(path)
|
30 |
+
return path
|
31 |
|
32 |
def get_stable_diffusion_image(prompt):
|
33 |
model_id = "CompVis/stable-diffusion-v1-4"
|
|
|
36 |
pipe = pipe.to(device)
|
37 |
with autocast("cuda"):
|
38 |
image = pipe(prompt, guidance_scale=7.5)["sample"][0]
|
39 |
+
path = "out.jpg"
|
40 |
+
image.save(path)
|
41 |
+
return path
|
42 |
|
43 |
|
44 |
+
iface = gr.Interface(fn=process_inputs, inputs=["text", gr.Audio(type="filepath")], outputs="video")
|
45 |
iface.launch()
|
out.jpg
ADDED
video_out.mp4
ADDED
Binary file (590 kB). View file
|
|