Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,28 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
|
|
|
| 4 |
|
| 5 |
-
# Load
|
| 6 |
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
| 7 |
-
pipe.to("cpu")
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
image = pipe(prompt).images[0]
|
| 12 |
-
|
|
|
|
| 13 |
|
| 14 |
-
# Gradio
|
| 15 |
demo = gr.Interface(
|
| 16 |
-
fn=
|
| 17 |
-
inputs=gr.Textbox(label="Enter your
|
| 18 |
-
outputs="
|
| 19 |
-
title="
|
| 20 |
-
description="
|
| 21 |
)
|
| 22 |
|
| 23 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
+
from transformers import pipeline
|
| 5 |
|
| 6 |
+
# 🎨 Load Stable Diffusion model
|
| 7 |
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0")
|
| 8 |
+
pipe.to("cpu")
|
| 9 |
|
| 10 |
+
# 🗣️ Load Text-to-Speech model
|
| 11 |
+
tts = pipeline("text-to-speech", model="nineninesix/kani-tts-370m")
|
| 12 |
+
|
| 13 |
+
# Image generation function
|
| 14 |
+
def generate_media(prompt):
|
| 15 |
image = pipe(prompt).images[0]
|
| 16 |
+
audio = tts(prompt)
|
| 17 |
+
return image, (audio["audio"],)
|
| 18 |
|
| 19 |
+
# Gradio UI
|
| 20 |
demo = gr.Interface(
|
| 21 |
+
fn=generate_media,
|
| 22 |
+
inputs=gr.Textbox(label="Enter your prompt"),
|
| 23 |
+
outputs=[gr.Image(label="Generated Image"), gr.Audio(label="AI Voice")],
|
| 24 |
+
title="AI Image + Voice Generator",
|
| 25 |
+
description="Generates an image with a matching AI voiceover using Stable Diffusion XL and KaniTTS"
|
| 26 |
)
|
| 27 |
|
| 28 |
demo.launch()
|