Update app.py
Browse files
app.py
CHANGED
@@ -200,10 +200,6 @@ if default_image:
|
|
200 |
else:
|
201 |
default_image = None
|
202 |
|
203 |
-
def on_demo_load(request: gr.Request):
|
204 |
-
url_params = gr.State()
|
205 |
-
print("url params", url_params, request)
|
206 |
-
|
207 |
with gr.Blocks(css=css,head=js,fill_height=True) as demo:
|
208 |
with gr.Row(equal_height=False):
|
209 |
with gr.Group():
|
@@ -223,10 +219,19 @@ with gr.Blocks(css=css,head=js,fill_height=True) as demo:
|
|
223 |
)
|
224 |
random_button = gr.Button("Surprise Me", scale=1, min_width=10)
|
225 |
run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
|
229 |
-
|
230 |
demo.load(fn=on_demo_load, inputs=[], outputs=[])#, js='''(img)=>checkDomain(img, "huggingface")''')
|
231 |
if __name__ == "__main__":
|
232 |
demo.queue().launch(show_api=False)
|
|
|
200 |
else:
|
201 |
default_image = None
|
202 |
|
|
|
|
|
|
|
|
|
203 |
with gr.Blocks(css=css,head=js,fill_height=True) as demo:
|
204 |
with gr.Row(equal_height=False):
|
205 |
with gr.Group():
|
|
|
219 |
)
|
220 |
random_button = gr.Button("Surprise Me", scale=1, min_width=10)
|
221 |
run_button = gr.Button( "GO!", scale=1, min_width=20, variant="primary",icon="https://huggingface.co/spaces/nsfwalex/sd_card/resolve/main/hot.svg")
|
222 |
+
|
223 |
+
def on_demo_load(request: gr.Request):
|
224 |
+
params = dict(request.query_params)
|
225 |
+
print("url params", params)
|
226 |
+
if params.get("e", "0") == "1":
|
227 |
+
#update the image
|
228 |
+
result.update(value=[default_image])
|
229 |
+
#bind events
|
230 |
+
random_button.click(fn=lambda x:x, inputs=[prompt], outputs=[prompt], js='''()=>window.g()''')
|
231 |
+
|
232 |
+
result.change(fn=lambda x:x, inputs=[prompt,result], outputs=[], js=f'''(p,img)=>window.uploadImage(p, img,"process_finished","demo_hf_{cfg.get("name")}_card", "finish")''')
|
233 |
run_button.click(generate, inputs=[prompt], outputs=[result], js=f'''(p)=>window.postMessageToParent(p,"process_started","demo_hf_{cfg.get("name")}_card", "click_go")''')
|
234 |
+
|
235 |
demo.load(fn=on_demo_load, inputs=[], outputs=[])#, js='''(img)=>checkDomain(img, "huggingface")''')
|
236 |
if __name__ == "__main__":
|
237 |
demo.queue().launch(show_api=False)
|