BeveledCube commited on
Commit
395adf9
1 Parent(s): f977a8b

Did an oopsie

Browse files
Files changed (2) hide show
  1. main.py +8 -6
  2. requirements.txt +2 -1
main.py CHANGED
@@ -1,17 +1,19 @@
1
  from diffusers import StableDiffusionPipeline
2
  import matplotlib.pyplot as plt
3
- import torch
4
 
5
  # Find models in https://huggingface.co/models?pipeline_tag=text-to-image&library=diffusers&sort=trending
6
- model_id = "stabilityai/stable-diffusion-xl-base-1.0"
7
 
8
- pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
9
- pipe = pipe.to("cuda")
10
 
11
  prompt = "beautiful horse"
12
 
13
  image = pipe(prompt).images[0]
14
 
 
 
 
15
  print("[PROMPT]: ", prompt)
16
- plt.imshow(image)
17
- plt.axis('off')
 
1
  from diffusers import StableDiffusionPipeline
2
  import matplotlib.pyplot as plt
 
3
 
4
  # Find models in https://huggingface.co/models?pipeline_tag=text-to-image&library=diffusers&sort=trending
5
+ model_id = "stabilityai/stable-diffusion-2-1"
6
 
7
+ pipe = StableDiffusionPipeline.from_pretrained(model_id)
8
+ pipe = pipe.to("cpu")
9
 
10
  prompt = "beautiful horse"
11
 
12
  image = pipe(prompt).images[0]
13
 
14
+ # Convert the torch Tensor to a NumPy array and move to CPU
15
+ image_np = image.cpu().numpy()
16
+
17
  print("[PROMPT]: ", prompt)
18
+ plt.axis('off')
19
+ plt.imsave('generated_image.png', image_np.transpose(1, 2, 0))
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  diffusers
2
- transformers
 
 
1
  diffusers
2
+ transformers
3
+ matplotlib