Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from diffusers import StableDiffusionPipeline
|
3 |
+
import torch
|
4 |
+
|
5 |
+
# Load Stable Diffusion model from Hugging Face
|
6 |
+
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v-1-4-original", torch_dtype=torch.float32)
|
7 |
+
pipe = pipe.to("cuda") # If you have a GPU available, use it. Otherwise, change to "cpu"
|
8 |
+
|
9 |
+
def generate_image(prompt):
|
10 |
+
image = pipe(prompt).images[0]
|
11 |
+
return image
|
12 |
+
|
13 |
+
# Set up the Gradio interface
|
14 |
+
gr.Interface(fn=generate_image, inputs="text", outputs="image").launch()
|