man08man's picture
Update app.py
19f9a8b verified
raw
history blame
639 Bytes
# Replace ALL code with this updated version
from diffusers import StableDiffusionPipeline
import torch
import random
def generate_image(prompt):
pipe = StableDiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-1",
torch_dtype=torch.float16,
use_safetensors=True, # Add this
variant="fp16" # Add this
)
seed = random.randint(0, 1000000)
generator = torch.Generator().manual_seed(seed)
image = pipe(
prompt,
generator=generator,
num_inference_steps=25
).images[0]
return image
# Rest of your Gradio code remains the same