tahirsher commited on
Commit
6aea10a
1 Parent(s): 39ab58d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,29 +1,27 @@
1
  import streamlit as st
2
- from PIL import Image
3
- import torch
4
 
5
- # Optimized lightweight image generation (example)
6
  @st.cache_resource
7
- def load_lightweight_model():
8
- # Assuming there's a lightweight model for CPU
9
- # Placeholder: Replace this with actual lightweight model loading
10
- return "lightweight_model"
11
 
12
- model = load_lightweight_model()
13
 
14
  # Streamlit app
15
- st.title("Text-to-Image Generation (Fast)")
16
 
17
  # User input for prompt
18
- user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle")
19
 
20
  # Button to generate the image
21
  if st.button("Generate Image"):
22
  if user_prompt:
23
  with st.spinner("Generating image..."):
24
- # Simulated fast image generation (substitute with lightweight model logic)
25
- # Example: Generate a simple placeholder image
26
- image = Image.new("RGB", (256, 256), color="blue") # Placeholder image
27
 
28
  # Display the generated image
29
  st.image(image, caption="Generated Image", use_column_width=True)
 
1
  import streamlit as st
2
+ from diffusers import DiffusionPipeline
 
3
 
4
+ # Load the diffusion pipeline model
5
  @st.cache_resource
6
+ def load_pipeline():
7
+ # Use the 'SaiRaj03/Text_To_Image' model for fast generation
8
+ pipe = DiffusionPipeline.from_pretrained("SaiRaj03/Text_To_Image")
9
+ return pipe
10
 
11
+ pipe = load_pipeline()
12
 
13
  # Streamlit app
14
+ st.title("Text-to-Image Generation App (Fast)")
15
 
16
  # User input for prompt
17
+ user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
18
 
19
  # Button to generate the image
20
  if st.button("Generate Image"):
21
  if user_prompt:
22
  with st.spinner("Generating image..."):
23
+ # Generate the image using the new model
24
+ image = pipe(user_prompt).images[0]
 
25
 
26
  # Display the generated image
27
  st.image(image, caption="Generated Image", use_column_width=True)