Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
-
# Stable Diffusion Hugging Face App (Turbo Version
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
from diffusers import StableDiffusionPipeline, DDIMScheduler
|
| 6 |
-
from transformers import CLIPTextModel, CLIPTokenizer
|
| 7 |
|
| 8 |
# Load the lightweight Stable Diffusion Turbo model
|
| 9 |
model_id = "stabilityai/sd-turbo"
|
|
@@ -35,9 +34,9 @@ def custom_loss_placeholder(image_tensor):
|
|
| 35 |
# Generate image based on prompt and style
|
| 36 |
|
| 37 |
def generate(prompt, style, seed):
|
| 38 |
-
torch.manual_seed(seed)
|
| 39 |
full_prompt = f"{prompt}, {STYLE_MAP.get(style, '')}"
|
| 40 |
-
result = pipe(full_prompt, guidance_scale=7.5).images[0]
|
| 41 |
return result
|
| 42 |
|
| 43 |
# Gradio UI
|
|
|
|
| 1 |
+
# Stable Diffusion Hugging Face App (Turbo Version with Fixes)
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
import torch
|
| 5 |
from diffusers import StableDiffusionPipeline, DDIMScheduler
|
|
|
|
| 6 |
|
| 7 |
# Load the lightweight Stable Diffusion Turbo model
|
| 8 |
model_id = "stabilityai/sd-turbo"
|
|
|
|
| 34 |
# Generate image based on prompt and style
|
| 35 |
|
| 36 |
def generate(prompt, style, seed):
|
| 37 |
+
generator = torch.manual_seed(seed)
|
| 38 |
full_prompt = f"{prompt}, {STYLE_MAP.get(style, '')}"
|
| 39 |
+
result = pipe(full_prompt, guidance_scale=7.5, generator=generator).images[0]
|
| 40 |
return result
|
| 41 |
|
| 42 |
# Gradio UI
|