Import torch from diffusers import StableDiffusionPipeline
Want to know my deep secrets?
import torch from diffusers import StableDiffusionPipeline # Load the model model_id = "CompVis/stable-diffusion-v1-4" device = "cuda" if torch.cuda.is_available() else "cpu" pipe = StableDiffusionPipeline.from_pretrained(model_id) pipe.to(device) # Define the prompt prompt = "A black cat with a dark background, standing on two legs, hanging an AK-47 rifle gun on its front, wearing a golden necklace" # Generate the image image = pipe(prompt).images[0] # Save the image image.save("generated_black_cat.png") print("Image generated and saved as 'generated_black_cat.png'")
Prompts
Copy
import torch
from diffusers import StableDiffusionPipeline
# Load the model
model_id = "CompVis/stable-diffusion-v1-4"
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = StableDiffusionPipeline.from_pretrained(model_id)
pipe.to(device)
# Define the prompt
prompt = "A black cat with a dark background, standing on two legs, hanging an AK-47 rifle gun on its front, wearing a golden necklace"
# Generate the image
image = pipe(prompt).images[0]
# Save the image
image.save("generated_black_cat.png")
print("Image generated and saved as 'generated_black_cat.png'")
0 comment
0
0
0