Waseem7711 commited on
Commit
7508b2b
·
verified ·
1 Parent(s): 72ed8d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -1,21 +1,21 @@
1
  import streamlit as st
2
- from diffusers import StableDiffusionPipeline
3
  import torch
4
  from PIL import Image
5
 
6
  # Streamlit App Title
7
  st.title("🖼️ Stable Diffusion Image Generator")
8
- st.write("Generate images from text prompts using Stable Diffusion 2.1!")
9
 
10
  # Sidebar for prompt input and button
11
  st.sidebar.title("Image Generation Settings")
12
  prompt = st.sidebar.text_input("Enter your prompt", "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
13
  generate_button = st.sidebar.button("Generate Image")
14
 
15
- # Cache the Stable Diffusion 2.1 model to load it only once
16
  @st.cache_resource
17
  def load_model():
18
- model = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
19
  model = model.to("cuda" if torch.cuda.is_available() else "cpu")
20
  return model
21
 
 
1
  import streamlit as st
2
+ from diffusers import DiffusionPipeline
3
  import torch
4
  from PIL import Image
5
 
6
  # Streamlit App Title
7
  st.title("🖼️ Stable Diffusion Image Generator")
8
+ st.write("Generate images from text prompts using Stable Diffusion!")
9
 
10
  # Sidebar for prompt input and button
11
  st.sidebar.title("Image Generation Settings")
12
  prompt = st.sidebar.text_input("Enter your prompt", "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k")
13
  generate_button = st.sidebar.button("Generate Image")
14
 
15
+ # Cache the Stable Diffusion model to load it only once
16
  @st.cache_resource
17
  def load_model():
18
+ model = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
19
  model = model.to("cuda" if torch.cuda.is_available() else "cpu")
20
  return model
21