Spaces:
Runtime error
Runtime error
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") | |