kasper-boy commited on
Commit
0ef42bc
·
verified ·
1 Parent(s): 8871405

Update Working_TTI_GPU.py

Browse files
Files changed (1) hide show
  1. Working_TTI_GPU.py +24 -0
Working_TTI_GPU.py CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from diffusers import DiffusionPipeline
2
+ import torch
3
+ from PIL import Image
4
+
5
+ # Load the model
6
+ pipe = DiffusionPipeline.from_pretrained(
7
+ "stabilityai/stable-diffusion-xl-base-1.0",
8
+ torch_dtype=torch.float16,
9
+ use_safetensors=True,
10
+ variant="fp16"
11
+ )
12
+ pipe.to("cuda")
13
+
14
+ # Define the prompt
15
+ prompt = "An astronaut riding a red horse"
16
+
17
+ # Generate the image
18
+ result = pipe(prompt=prompt)
19
+ image = result.images[0]
20
+
21
+ # Save the image
22
+ image.save("generated_image.png")
23
+
24
+ print("Image saved as generated_image.png")