Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,31 +1,17 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from diffusers import DDPMPipeline
|
| 3 |
import PIL
|
| 4 |
-
import time
|
| 5 |
-
import threading
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
pipeline = DDPMPipeline.from_pretrained('dvoils/sd-class-butterflies-32')
|
| 16 |
-
self.image = pipeline().images[0]
|
| 17 |
-
self.done = True
|
| 18 |
|
| 19 |
if st.button('Generate Image'):
|
| 20 |
-
generator = ImageGenerator()
|
| 21 |
-
thread = threading.Thread(target=generator.long_running_task)
|
| 22 |
-
thread.start()
|
| 23 |
-
|
| 24 |
with st.spinner('Generating Image...'):
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
for i in range(100):
|
| 28 |
-
time.sleep(0.01)
|
| 29 |
-
progress_bar.progress(i + 1)
|
| 30 |
-
progress_bar.progress(0)
|
| 31 |
-
st.image(generator.image, caption='Generated Image', use_column_width=True)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from diffusers import DDPMPipeline
|
| 3 |
import PIL
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
# Use the cache decorator to only re-run when the inputs change
|
| 6 |
+
@st.cache(suppress_st_warning=True, allow_output_mutation=True)
|
| 7 |
+
def generate_image():
|
| 8 |
+
pipeline = DDPMPipeline.from_pretrained('dvoils/sd-class-butterflies-32')
|
| 9 |
+
image = pipeline().images[0]
|
| 10 |
+
return image
|
| 11 |
|
| 12 |
+
st.title('DDPMPipeline Image Generator')
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
if st.button('Generate Image'):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with st.spinner('Generating Image...'):
|
| 16 |
+
image = generate_image()
|
| 17 |
+
st.image(image, caption='Generated Image', use_column_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|