Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,19 +5,19 @@ from PIL import Image
|
|
5 |
|
6 |
# Title and description of the app
|
7 |
st.title("🖼️ Stable Diffusion Image Generator")
|
8 |
-
st.write("Generate images from text using the Stable Diffusion
|
9 |
|
10 |
# Sidebar for user inputs
|
11 |
st.sidebar.title("Input Options")
|
12 |
-
prompt = st.sidebar.text_input("Enter your prompt", "
|
13 |
generate_button = st.sidebar.button("Generate Image")
|
14 |
|
15 |
# Load the pipeline when the app starts
|
16 |
@st.cache_resource
|
17 |
def load_pipeline():
|
18 |
-
# Use a smaller
|
19 |
pipe = StableDiffusionPipeline.from_pretrained(
|
20 |
-
"
|
21 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
22 |
revision="fp16" if torch.cuda.is_available() else None
|
23 |
)
|
@@ -49,6 +49,5 @@ if generate_button:
|
|
49 |
file_name="generated_image.png",
|
50 |
mime="image/png"
|
51 |
)
|
52 |
-
# print
|
53 |
except Exception as e:
|
54 |
st.error(f"An error occurred: {e}")
|
|
|
5 |
|
6 |
# Title and description of the app
|
7 |
st.title("🖼️ Stable Diffusion Image Generator")
|
8 |
+
st.write("Generate images from text using the Stable Diffusion v2-1 model!")
|
9 |
|
10 |
# Sidebar for user inputs
|
11 |
st.sidebar.title("Input Options")
|
12 |
+
prompt = st.sidebar.text_input("Enter your prompt", "A futuristic cityscape at sunset, vibrant colors, 8k")
|
13 |
generate_button = st.sidebar.button("Generate Image")
|
14 |
|
15 |
# Load the pipeline when the app starts
|
16 |
@st.cache_resource
|
17 |
def load_pipeline():
|
18 |
+
# Use a smaller and more efficient model
|
19 |
pipe = StableDiffusionPipeline.from_pretrained(
|
20 |
+
"stabilityai/stable-diffusion-2-1",
|
21 |
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
22 |
revision="fp16" if torch.cuda.is_available() else None
|
23 |
)
|
|
|
49 |
file_name="generated_image.png",
|
50 |
mime="image/png"
|
51 |
)
|
|
|
52 |
except Exception as e:
|
53 |
st.error(f"An error occurred: {e}")
|