pratikshahp commited on
Commit
4f953de
1 Parent(s): e4b219b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -11
app.py CHANGED
@@ -3,31 +3,23 @@ from PIL import Image
3
  import torch
4
  from diffusers import StableDiffusionPipeline
5
 
6
- #choice = st.sidebar.selectbox("Enter Your Choice",["Home","DALL-E","Diffusers"])
7
- #if choice == "Home":
8
- #st.title("Text to Image Generation App!")
9
- #elif choice == "DALL-E"
10
- # st.subheader("Text to image generation with DALL-E")
11
- #else:
12
- # st.subheader("Text to image generation with Diffusers")
13
-
14
  def generate_image(input_text):
15
  # Load Diffusion pipeline
16
- pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",torch_dtype=torch.float16)
17
  # Generate image from text prompt
18
- pipe = pipe.to("cuda")
19
  prompt = input_text
20
  generated_image = pipe(prompt).images[0]
21
  return generated_image
22
 
23
  # Set Streamlit app title
24
  st.title("Text to Image Generation App")
 
25
  # Text input for prompt
26
  input_text = st.text_input("Enter your image description:", "")
 
27
  # Button to generate image
28
  if st.button("Generate Image"):
29
  # Generate image based on the prompt
30
- st.info(input_text)
31
  img = generate_image(input_text)
32
 
33
  # Display the generated image
 
3
  import torch
4
  from diffusers import StableDiffusionPipeline
5
 
 
 
 
 
 
 
 
 
6
  def generate_image(input_text):
7
  # Load Diffusion pipeline
8
+ pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
9
  # Generate image from text prompt
 
10
  prompt = input_text
11
  generated_image = pipe(prompt).images[0]
12
  return generated_image
13
 
14
  # Set Streamlit app title
15
  st.title("Text to Image Generation App")
16
+
17
  # Text input for prompt
18
  input_text = st.text_input("Enter your image description:", "")
19
+
20
  # Button to generate image
21
  if st.button("Generate Image"):
22
  # Generate image based on the prompt
 
23
  img = generate_image(input_text)
24
 
25
  # Display the generated image