Spaces:
Build error
Build error
Rename app.py to space.py
Browse files
app.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import subprocess
|
| 3 |
-
|
| 4 |
-
def launch_sd():
|
| 5 |
-
return "Starting Stable Diffusion WebUI..."
|
| 6 |
-
|
| 7 |
-
with gr.Blocks() as demo:
|
| 8 |
-
gr.Markdown("# Stable Diffusion WebUI")
|
| 9 |
-
gr.Button("Launch", variant="primary").click(launch_sd)
|
| 10 |
-
|
| 11 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
space.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Load the model (you can use Hugging Face's pretrained model)
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v-1-4-original")
|
| 7 |
+
pipe = pipe.to("cuda")
|
| 8 |
+
|
| 9 |
+
def generate_image(prompt):
|
| 10 |
+
image = pipe(prompt).images[0]
|
| 11 |
+
return image
|
| 12 |
+
|
| 13 |
+
# Create the Gradio interface
|
| 14 |
+
iface = gr.Interface(fn=generate_image, inputs="text", outputs="image", live=True)
|
| 15 |
+
|
| 16 |
+
iface.launch()
|