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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -1,29 +1,29 @@
1
  import streamlit as st
2
- from diffusers import DiffusionPipeline
3
  from PIL import Image
4
  import torch
5
 
6
- # Load the diffusion pipeline model
7
  @st.cache_resource
8
- def load_pipeline():
9
- pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
10
- pipe.load_lora_weights("Melonie/text_to_image_finetuned")
11
- return pipe
12
 
13
- pipe = load_pipeline()
14
 
15
  # Streamlit app
16
- st.title("Text-to-Image Generation App")
17
 
18
  # User input for prompt
19
- user_prompt = st.text_input("Enter your image prompt", value="Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
20
 
21
  # Button to generate the image
22
  if st.button("Generate Image"):
23
  if user_prompt:
24
  with st.spinner("Generating image..."):
25
- # Generate the image
26
- image = pipe(user_prompt).images[0]
 
27
 
28
  # Display the generated image
29
  st.image(image, caption="Generated Image", use_column_width=True)
 
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)