Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -29,8 +29,6 @@ import json
|
|
29 |
import os
|
30 |
import glob
|
31 |
import pathlib
|
32 |
-
import base64
|
33 |
-
from io import BytesIO
|
34 |
from functools import partial
|
35 |
from pprint import pprint
|
36 |
|
@@ -45,7 +43,7 @@ import spaces
|
|
45 |
from model import StableMultiDiffusionSDXLPipeline
|
46 |
from util import seed_everything
|
47 |
from prompt_util import preprocess_prompts, _quality_dict, _style_dict
|
48 |
-
from share_btn import
|
49 |
|
50 |
|
51 |
### Utils
|
@@ -377,12 +375,6 @@ def run(state, drawpad):
|
|
377 |
)
|
378 |
return image
|
379 |
|
380 |
-
# buffered = BytesIO()
|
381 |
-
# image.save(buffered, format="JPEG")
|
382 |
-
# img_str = base64.b64encode(buffered.getvalue())
|
383 |
-
# return image, img_str
|
384 |
-
|
385 |
-
|
386 |
|
387 |
### Load examples
|
388 |
|
@@ -456,44 +448,19 @@ css = f"""
|
|
456 |
display: none;
|
457 |
}}
|
458 |
|
459 |
-
#share-btn
|
460 |
-
|
461 |
-
padding-left: 0.5rem !important;
|
462 |
-
padding-right: 0.5rem !important;
|
463 |
background-color: #000000;
|
464 |
-
|
465 |
-
align-items: center;
|
466 |
border-radius: 9999px !important;
|
467 |
-
width: 13rem;
|
468 |
-
margin-top: 10px;
|
469 |
-
margin-left: auto;
|
470 |
}}
|
471 |
|
472 |
-
#share-btn {{
|
473 |
-
all: initial;
|
474 |
color: #ffffff;font-weight: 600;
|
475 |
-
|
476 |
font-family: 'IBM Plex Sans', sans-serif;
|
477 |
-
|
478 |
-
|
479 |
-
padding-bottom: 0.25rem !important;right:0;
|
480 |
-
}}
|
481 |
-
|
482 |
-
#share-btn * {{
|
483 |
-
all: unset;
|
484 |
-
}}
|
485 |
-
|
486 |
-
#share-btn-container div:nth-child(-n+2){{
|
487 |
-
width: auto !important;
|
488 |
-
min-height: 0px !important;
|
489 |
-
}}
|
490 |
-
|
491 |
-
#share-btn-container .wrap {{
|
492 |
-
display: none !important;
|
493 |
-
}}
|
494 |
-
|
495 |
-
#output-b64 {{
|
496 |
-
display: none !important;
|
497 |
}}
|
498 |
"""
|
499 |
|
@@ -716,11 +683,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
716 |
# scale=1,
|
717 |
elem_id='run-button'
|
718 |
)
|
719 |
-
|
720 |
-
# gr.HTML(community_icon_html)
|
721 |
-
# gr.HTML(loading_icon_html)
|
722 |
-
# iface.btn_share = gr.Button('Share with Community', elem_id='share-btn')
|
723 |
-
# iface.image_b64 = gr.Textbox(elem_id='output-b64')
|
724 |
|
725 |
iface.model_select = gr.Radio(
|
726 |
list(model_dict.keys()),
|
@@ -833,7 +796,6 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
833 |
iface.btn_generate.click(
|
834 |
fn=run,
|
835 |
inputs=[state, iface.ctrl_semantic],
|
836 |
-
# outputs=[iface.image_slot, iface.image_b64],
|
837 |
outputs=iface.image_slot,
|
838 |
api_name='run',
|
839 |
)
|
@@ -901,7 +863,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
901 |
api_name='quality_select',
|
902 |
)
|
903 |
|
904 |
-
|
905 |
|
906 |
iface.btn_export_state.click(lambda x: vars(x), state, iface.json_state_export)
|
907 |
iface.btn_import_state.click(import_state, [state, iface.tbox_state_import], [
|
|
|
29 |
import os
|
30 |
import glob
|
31 |
import pathlib
|
|
|
|
|
32 |
from functools import partial
|
33 |
from pprint import pprint
|
34 |
|
|
|
43 |
from model import StableMultiDiffusionSDXLPipeline
|
44 |
from util import seed_everything
|
45 |
from prompt_util import preprocess_prompts, _quality_dict, _style_dict
|
46 |
+
from share_btn import share_js
|
47 |
|
48 |
|
49 |
### Utils
|
|
|
375 |
)
|
376 |
return image
|
377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
|
379 |
### Load examples
|
380 |
|
|
|
448 |
display: none;
|
449 |
}}
|
450 |
|
451 |
+
#share-btn {{
|
452 |
+
color: #ffffff;font-weight: 600;
|
|
|
|
|
453 |
background-color: #000000;
|
454 |
+
font-family: 'IBM Plex Sans', sans-serif;
|
|
|
455 |
border-radius: 9999px !important;
|
|
|
|
|
|
|
456 |
}}
|
457 |
|
458 |
+
#share-btn:hover {{
|
|
|
459 |
color: #ffffff;font-weight: 600;
|
460 |
+
background-color: #000000;
|
461 |
font-family: 'IBM Plex Sans', sans-serif;
|
462 |
+
border-radius: 9999px !important;
|
463 |
+
box-shadow: 0 0 20px #eee;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
}}
|
465 |
"""
|
466 |
|
|
|
683 |
# scale=1,
|
684 |
elem_id='run-button'
|
685 |
)
|
686 |
+
iface.btn_share = gr.Button('🤗 Share with Community', elem_id='share-btn')
|
|
|
|
|
|
|
|
|
687 |
|
688 |
iface.model_select = gr.Radio(
|
689 |
list(model_dict.keys()),
|
|
|
796 |
iface.btn_generate.click(
|
797 |
fn=run,
|
798 |
inputs=[state, iface.ctrl_semantic],
|
|
|
799 |
outputs=iface.image_slot,
|
800 |
api_name='run',
|
801 |
)
|
|
|
863 |
api_name='quality_select',
|
864 |
)
|
865 |
|
866 |
+
iface.btn_share.click(None, [], [], js=share_js)
|
867 |
|
868 |
iface.btn_export_state.click(lambda x: vars(x), state, iface.json_state_export)
|
869 |
iface.btn_import_state.click(import_state, [state, iface.tbox_state_import], [
|