pratikshahp commited on
Commit
bf1fe95
1 Parent(s): 6c92334

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -5,31 +5,29 @@ 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(prompt):
15
  # Load Diffusion pipeline
16
- pipe = StableDiffusionPipeline.from_pretrained("fluently/Fluently-XL-v2",torch_dtype=torch.float16)
17
-
18
  # Generate image from text prompt
 
19
  generated_image = pipe(prompt).images[0]
20
-
21
  return generated_image
22
 
23
  # Set Streamlit app title
24
- #st.title("Text to Image Generation")
25
-
26
  # Text input for prompt
27
- prompt = st.text_input("Enter your image description:", "")
28
-
29
  # Button to generate image
30
  if st.button("Generate Image"):
31
  # Generate image based on the prompt
32
- generated_image = generate_image(prompt)
 
33
 
34
  # Display the generated image
35
- st.image(generated_image, caption="Generated Image", use_column_width=True)
 
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
+ prompt = input_text
19
  generated_image = pipe(prompt).images[0]
 
20
  return generated_image
21
 
22
  # Set Streamlit app title
23
+ st.title("Text to Image Generation App")
 
24
  # Text input for prompt
25
+ input_text = st.text_input("Enter your image description:", "")
 
26
  # Button to generate image
27
  if st.button("Generate Image"):
28
  # Generate image based on the prompt
29
+ st.info(input_text)
30
+ img = generate_image(input_text)
31
 
32
  # Display the generated image
33
+ st.image(img, caption="Generated Image")