Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -93,8 +93,7 @@ def generate(
|
|
93 |
images.extend(pipe(**batch_options).images)
|
94 |
|
95 |
image_paths = [save_image(img) for img in images]
|
96 |
-
|
97 |
-
return image_paths, seed, gr.update(visible=False)
|
98 |
|
99 |
examples = [
|
100 |
"a cat eating a piece of cheese",
|
@@ -113,7 +112,24 @@ footer {
|
|
113 |
}
|
114 |
'''
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
|
117 |
gr.Markdown(DESCRIPTIONx)
|
118 |
with gr.Group():
|
119 |
with gr.Row():
|
@@ -125,14 +141,7 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
125 |
container=False,
|
126 |
)
|
127 |
run_button = gr.Button("Run", scale=0)
|
128 |
-
result = gr.Gallery(label="Result", columns=1, show_label=False)
|
129 |
-
loading_animation = gr.HTML(
|
130 |
-
"""
|
131 |
-
<div id="loading-animation" style="display:none;">
|
132 |
-
<iframe src="https://prithivmlmods-hamster-static.static.hf.space/index.html" width="100%" height="200" style="border:none;"></iframe>
|
133 |
-
</div>
|
134 |
-
"""
|
135 |
-
)
|
136 |
with gr.Accordion("Advanced options", open=False):
|
137 |
num_images = gr.Slider(
|
138 |
label="Number of Images",
|
@@ -203,7 +212,14 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
203 |
api_name=False,
|
204 |
)
|
205 |
|
206 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
207 |
prompt,
|
208 |
negative_prompt,
|
209 |
use_negative_prompt,
|
@@ -214,20 +230,12 @@ with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
|
214 |
num_inference_steps,
|
215 |
randomize_seed,
|
216 |
num_images
|
217 |
-
],
|
|
|
|
|
|
|
218 |
|
219 |
-
|
220 |
-
prompt,
|
221 |
-
negative_prompt,
|
222 |
-
use_negative_prompt,
|
223 |
-
seed,
|
224 |
-
width,
|
225 |
-
height,
|
226 |
-
guidance_scale,
|
227 |
-
num_inference_steps,
|
228 |
-
randomize_seed,
|
229 |
-
num_images
|
230 |
-
], outputs=[result, seed, loading_animation], queue=True)
|
231 |
|
232 |
if __name__ == "__main__":
|
233 |
demo.queue(max_size=50).launch()
|
|
|
93 |
images.extend(pipe(**batch_options).images)
|
94 |
|
95 |
image_paths = [save_image(img) for img in images]
|
96 |
+
return image_paths, seed
|
|
|
97 |
|
98 |
examples = [
|
99 |
"a cat eating a piece of cheese",
|
|
|
112 |
}
|
113 |
'''
|
114 |
|
115 |
+
loading_html = """
|
116 |
+
<div id="loading" style="display: flex; justify-content: center; align-items: center; height: 100vh;">
|
117 |
+
<iframe src="https://prithivmlmods-hamster-static.static.hf.space/index.html" style="border: none; width: 100%; height: 100%;"></iframe>
|
118 |
+
</div>
|
119 |
+
<div id="app" style="display: none;">
|
120 |
+
"""
|
121 |
+
|
122 |
+
loading_js = """
|
123 |
+
<script>
|
124 |
+
setTimeout(() => {
|
125 |
+
document.getElementById('loading').style.display = 'none';
|
126 |
+
document.getElementById('app').style.display = 'block';
|
127 |
+
}, 5000); // 5000 milliseconds = 5 seconds
|
128 |
+
</script>
|
129 |
+
"""
|
130 |
+
|
131 |
with gr.Blocks(css=css, theme="bethecloud/storj_theme") as demo:
|
132 |
+
gr.HTML(loading_html)
|
133 |
gr.Markdown(DESCRIPTIONx)
|
134 |
with gr.Group():
|
135 |
with gr.Row():
|
|
|
141 |
container=False,
|
142 |
)
|
143 |
run_button = gr.Button("Run", scale=0)
|
144 |
+
result = gr.Gallery(label="Result", columns=1, show_label=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
with gr.Accordion("Advanced options", open=False):
|
146 |
num_images = gr.Slider(
|
147 |
label="Number of Images",
|
|
|
212 |
api_name=False,
|
213 |
)
|
214 |
|
215 |
+
gr.on(
|
216 |
+
triggers=[
|
217 |
+
prompt.submit,
|
218 |
+
negative_prompt.submit,
|
219 |
+
run_button.click,
|
220 |
+
],
|
221 |
+
fn=generate,
|
222 |
+
inputs=[
|
223 |
prompt,
|
224 |
negative_prompt,
|
225 |
use_negative_prompt,
|
|
|
230 |
num_inference_steps,
|
231 |
randomize_seed,
|
232 |
num_images
|
233 |
+
],
|
234 |
+
outputs=[result, seed],
|
235 |
+
api_name="run",
|
236 |
+
)
|
237 |
|
238 |
+
gr.HTML(loading_js)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
if __name__ == "__main__":
|
241 |
demo.queue(max_size=50).launch()
|