lelafav502 commited on
Commit
1d99d08
·
1 Parent(s): cc7ab21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -1,5 +1,21 @@
1
- import gradio as gr
2
-
 
 
3
 
4
  # Load the model
5
- gr.load("CompVis/stable-diffusion-v1-4").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from diffusers import StableDiffusionPipeline
3
+ from PIL import Image
4
+ import io
5
 
6
  # Load the model
7
+ pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
8
+ pipe = pipe.to("cuda")
9
+
10
+ def generate_image(prompt):
11
+ image = pipe(prompt).images[0]
12
+ return image
13
+
14
+ # Take prompt as input
15
+ prompt = input("Enter a prompt: ")
16
+
17
+ # Generate the image
18
+ generated_image = generate_image(prompt)
19
+
20
+ # Display the generated image
21
+ generated_image.show()