-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate_image.py
30 lines (26 loc) · 1.08 KB
/
generate_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit as st
import replicate
import time
def generate_image():
st.subheader("Generate Image")
prompt = st.text_input(label="Enter a prompt for the image:", key="generate_image_prompt")
if st.button("Generate Image", key="generate_image_button"):
with st.spinner("Generating image..."):
start_time = time.time()
output = replicate.run(
"stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
input={
"width": 1024,
"height": 1024,
"prompt": prompt,
"refine": "expert_ensemble_refiner",
"num_outputs": 1,
"apply_watermark": False,
"negative_prompt": "low quality, worst quality",
"num_inference_steps": 25
}
)
st.image(output)
end_time = time.time()
elapsed_time = end_time - start_time
st.write(f"Image generated in {elapsed_time:.2f} seconds")