Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,11 +25,12 @@ def text_to_speech(text, output_path="output.mp3"):
|
|
| 25 |
|
| 26 |
# Function to generate images from a text prompt using Stable Diffusion (CPU)
|
| 27 |
def generate_images_from_prompt(prompt, num_images=5):
|
| 28 |
-
model_id = "
|
| 29 |
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
|
|
|
| 30 |
images = []
|
| 31 |
for i in range(num_images):
|
| 32 |
-
image = pipe(prompt, num_inference_steps=50)[
|
| 33 |
image_path = f"image_{i}.png"
|
| 34 |
image.save(image_path)
|
| 35 |
images.append(image_path)
|
|
@@ -56,7 +57,7 @@ def create_video(images, audio_path, output_video_path="output.mp4"):
|
|
| 56 |
def generate_video_from_prompt(prompt):
|
| 57 |
script = generate_script(prompt)
|
| 58 |
audio_path = text_to_speech(script)
|
| 59 |
-
images = generate_images_from_prompt(
|
| 60 |
create_video(images, audio_path)
|
| 61 |
return "output.mp4"
|
| 62 |
|
|
|
|
| 25 |
|
| 26 |
# Function to generate images from a text prompt using Stable Diffusion (CPU)
|
| 27 |
def generate_images_from_prompt(prompt, num_images=5):
|
| 28 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 29 |
pipe = StableDiffusionPipeline.from_pretrained(model_id)
|
| 30 |
+
pipe = pipe.to("cpu") # Ensure we are using CPU
|
| 31 |
images = []
|
| 32 |
for i in range(num_images):
|
| 33 |
+
image = pipe(prompt, num_inference_steps=50).images[0]
|
| 34 |
image_path = f"image_{i}.png"
|
| 35 |
image.save(image_path)
|
| 36 |
images.append(image_path)
|
|
|
|
| 57 |
def generate_video_from_prompt(prompt):
|
| 58 |
script = generate_script(prompt)
|
| 59 |
audio_path = text_to_speech(script)
|
| 60 |
+
images = generate_images_from_prompt(prompt)
|
| 61 |
create_video(images, audio_path)
|
| 62 |
return "output.mp4"
|
| 63 |
|