Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,14 @@ import gradio as gr
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def generate_image(prompt, guidance_scale=7.5, num_inference_steps=50):
|
| 10 |
image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
|
|
|
|
| 2 |
from diffusers import StableDiffusionPipeline
|
| 3 |
import torch
|
| 4 |
|
| 5 |
+
# Выбираем модель, которая точно поддерживает CPU
|
| 6 |
+
model_id = "runwayml/stable-diffusion-v1-5"
|
| 7 |
+
|
| 8 |
+
# Отключаем использование высокопроизводительных инструкций xFormers, так как они не нужны на CPU
|
| 9 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, use_auth_token=True, variant="fp16", revision="fp16")
|
| 10 |
+
|
| 11 |
+
# Не перемещаем модель на GPU
|
| 12 |
+
# pipe = pipe.to("cuda")
|
| 13 |
|
| 14 |
def generate_image(prompt, guidance_scale=7.5, num_inference_steps=50):
|
| 15 |
image = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=num_inference_steps).images[0]
|