Spaces:
Runtime error
Runtime error
File size: 518 Bytes
b74bad5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
from diffusers import DiffusionPipeline
import torch
from PIL import Image
# Load the model
pipe = DiffusionPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
torch_dtype=torch.float32, # Use float32 for CPU
use_safetensors=True
)
pipe.to("cpu")
# Define the prompt
prompt = "An astronaut riding a green horse"
# Generate the image
result = pipe(prompt=prompt)
image = result.images[0]
# Save the image
image.save("generated_image.png")
print("Image saved as generated_image.png")
|