Views
No views yet
pip install torch transformers diffusers pillowpip install diffusers1from diffusers import StableDiffusionPipeline
2
3# Replace 'your-model-id' with the actual model ID on Hugging Face
4model_id = "your-model-id"
5pipeline = StableDiffusionPipeline.from_pretrained(model_id)1from diffusers import StableDiffusionPipeline
2import torch
3
4# Load the model
5model_id = "your-model-id"
6pipeline = StableDiffusionPipeline.from_pretrained(model_id)
7pipeline.to("cuda") # Use GPU if available
8
9# Generate an image from text
10prompt = "A beautiful sunset over the mountains"
11image = pipeline(prompt).images[0]
12
13# Save the generated image
14image.save("generated_image.png")