Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -29,6 +29,8 @@ import json
|
|
29 |
import os
|
30 |
import glob
|
31 |
import pathlib
|
|
|
|
|
32 |
from functools import partial
|
33 |
from pprint import pprint
|
34 |
|
@@ -357,7 +359,7 @@ def run(state, drawpad):
|
|
357 |
prompts, negative_prompts = preprocess_prompts(
|
358 |
prompts, negative_prompts, style_name=state.style_name, quality_name=state.quality_name)
|
359 |
|
360 |
-
|
361 |
state,
|
362 |
prompts,
|
363 |
negative_prompts,
|
@@ -374,6 +376,11 @@ def run(state, drawpad):
|
|
374 |
guidance_scale=0,
|
375 |
)
|
376 |
|
|
|
|
|
|
|
|
|
|
|
377 |
|
378 |
|
379 |
### Load examples
|
@@ -704,10 +711,11 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
704 |
# scale=1,
|
705 |
elem_id='run-button'
|
706 |
)
|
707 |
-
with gr.Group(elem_id=
|
708 |
gr.HTML(community_icon_html)
|
709 |
gr.HTML(loading_icon_html)
|
710 |
-
iface.btn_share = gr.Button(
|
|
|
711 |
|
712 |
iface.model_select = gr.Radio(
|
713 |
list(model_dict.keys()),
|
@@ -820,7 +828,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
|
820 |
iface.btn_generate.click(
|
821 |
fn=run,
|
822 |
inputs=[state, iface.ctrl_semantic],
|
823 |
-
outputs=iface.image_slot,
|
824 |
api_name='run',
|
825 |
)
|
826 |
|
|
|
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 |
|
|
|
359 |
prompts, negative_prompts = preprocess_prompts(
|
360 |
prompts, negative_prompts, style_name=state.style_name, quality_name=state.quality_name)
|
361 |
|
362 |
+
image = generate(
|
363 |
state,
|
364 |
prompts,
|
365 |
negative_prompts,
|
|
|
376 |
guidance_scale=0,
|
377 |
)
|
378 |
|
379 |
+
buffered = BytesIO()
|
380 |
+
image.save(buffered, format="JPEG")
|
381 |
+
img_str = base64.b64encode(buffered.getvalue())
|
382 |
+
return image, img_str
|
383 |
+
|
384 |
|
385 |
|
386 |
### Load examples
|
|
|
711 |
# scale=1,
|
712 |
elem_id='run-button'
|
713 |
)
|
714 |
+
with gr.Group(elem_id='share-btn-container'):
|
715 |
gr.HTML(community_icon_html)
|
716 |
gr.HTML(loading_icon_html)
|
717 |
+
iface.btn_share = gr.Button('Share with Community', elem_id='share-btn')
|
718 |
+
iface.image_b64 = gr.Textbox(visible=False, elem_id='output-b64')
|
719 |
|
720 |
iface.model_select = gr.Radio(
|
721 |
list(model_dict.keys()),
|
|
|
828 |
iface.btn_generate.click(
|
829 |
fn=run,
|
830 |
inputs=[state, iface.ctrl_semantic],
|
831 |
+
outputs=[iface.image_slot, iface.image_b64],
|
832 |
api_name='run',
|
833 |
)
|
834 |
|