Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,19 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# Выполняем другие необходимые команды, например, установка зависимостей
|
| 10 |
-
os.system("pip install -r stable-diffusion-webui-forge/requirements.txt")
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
|
| 5 |
+
# Используем официальную модель
|
| 6 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
| 7 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 8 |
+
pipe.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 9 |
|
| 10 |
+
def generate_image(prompt):
|
| 11 |
+
image = pipe(prompt).images[0]
|
| 12 |
+
return image
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
gr.Interface(
|
| 15 |
+
fn=generate_image,
|
| 16 |
+
inputs="text",
|
| 17 |
+
outputs="image",
|
| 18 |
+
title="Stable Diffusion WebUI"
|
| 19 |
+
).launch()
|