Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,8 @@ import torch
|
|
6 |
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
|
7 |
pipe.to("cpu")
|
8 |
|
|
|
|
|
9 |
def generate_image(prompt):
|
10 |
# Generate image using the model
|
11 |
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
|
@@ -23,3 +25,4 @@ if st.button("Generate Image"):
|
|
23 |
st.image(generate_image(prompt), caption="Generated Image", use_column_width=True)
|
24 |
else:
|
25 |
st.warning("Please enter a prompt.")
|
|
|
|
6 |
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16")
|
7 |
pipe.to("cpu")
|
8 |
|
9 |
+
# Cache the image generation function
|
10 |
+
@st.cache(suppress_st_warning=True)
|
11 |
def generate_image(prompt):
|
12 |
# Generate image using the model
|
13 |
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
|
|
|
25 |
st.image(generate_image(prompt), caption="Generated Image", use_column_width=True)
|
26 |
else:
|
27 |
st.warning("Please enter a prompt.")
|
28 |
+
|