Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,7 @@ from diffusers import StableDiffusionPipeline
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
# Load model (optimized for Hugging Face Spaces)
|
| 6 |
-
model_id = "
|
| 7 |
-
|
| 8 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 9 |
model_id,
|
| 10 |
torch_dtype=torch.float16
|
|
@@ -19,12 +18,13 @@ pipe.enable_attention_slicing()
|
|
| 19 |
|
| 20 |
# Image generation function
|
| 21 |
def generate_image(prompt):
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
| 26 |
return image
|
| 27 |
-
|
| 28 |
# Gradio UI
|
| 29 |
interface = gr.Interface(
|
| 30 |
fn=generate_image,
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
# Load model (optimized for Hugging Face Spaces)
|
| 6 |
+
model_id = "stabilityai/sd-turbo"
|
|
|
|
| 7 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 8 |
model_id,
|
| 9 |
torch_dtype=torch.float16
|
|
|
|
| 18 |
|
| 19 |
# Image generation function
|
| 20 |
def generate_image(prompt):
|
| 21 |
+
image = pipe(
|
| 22 |
+
prompt,
|
| 23 |
+
num_inference_steps=20, # reduce from default (~50)
|
| 24 |
+
guidance_scale=7.5
|
| 25 |
+
).images[0]
|
| 26 |
return image
|
| 27 |
+
|
| 28 |
# Gradio UI
|
| 29 |
interface = gr.Interface(
|
| 30 |
fn=generate_image,
|