Spaces:
Runtime error
Runtime error
root
commited on
Commit
•
f5e005e
1
Parent(s):
9bb9db4
add share button
Browse files- app.py +12 -1
- share_btn.py +1 -1
app.py
CHANGED
@@ -8,6 +8,7 @@ import json
|
|
8 |
import ui_functions as uifn
|
9 |
from css_and_js import js, call_JS
|
10 |
import re
|
|
|
11 |
|
12 |
txt2img_defaults = {
|
13 |
'prompt': '',
|
@@ -213,7 +214,10 @@ if __name__ == "__main__":
|
|
213 |
|
214 |
with block:
|
215 |
gr.HTML(read_content("header.html"))
|
216 |
-
|
|
|
|
|
|
|
217 |
with gr.Tabs(elem_id='tabss') as tabs:
|
218 |
|
219 |
with gr.TabItem("文生图(Text-to-img)", id='txt2img_tab'):
|
@@ -568,6 +572,13 @@ if __name__ == "__main__":
|
|
568 |
img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
|
569 |
outputs=img2img_dimensions_info_text_box)
|
570 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
gr.HTML(read_content("footer.html"))
|
572 |
# gr.Image('./contributors.png')
|
573 |
|
|
|
8 |
import ui_functions as uifn
|
9 |
from css_and_js import js, call_JS
|
10 |
import re
|
11 |
+
from share_btn import community_icon_html, loading_icon_html, share_js
|
12 |
|
13 |
txt2img_defaults = {
|
14 |
'prompt': '',
|
|
|
214 |
|
215 |
with block:
|
216 |
gr.HTML(read_content("header.html"))
|
217 |
+
with gr.Group(elem_id="share-btn-container"):
|
218 |
+
community_icon = gr.HTML(community_icon_html)
|
219 |
+
loading_icon = gr.HTML(loading_icon_html)
|
220 |
+
share_button = gr.Button("Share to community", elem_id="share-btn")
|
221 |
with gr.Tabs(elem_id='tabss') as tabs:
|
222 |
|
223 |
with gr.TabItem("文生图(Text-to-img)", id='txt2img_tab'):
|
|
|
572 |
img2img_height.change(fn=uifn.update_dimensions_info, inputs=[img2img_width, img2img_height],
|
573 |
outputs=img2img_dimensions_info_text_box)
|
574 |
|
575 |
+
share_button.click(
|
576 |
+
None,
|
577 |
+
[],
|
578 |
+
[],
|
579 |
+
_js=share_js,
|
580 |
+
)
|
581 |
+
|
582 |
gr.HTML(read_content("footer.html"))
|
583 |
# gr.Image('./contributors.png')
|
584 |
|
share_btn.py
CHANGED
@@ -53,7 +53,7 @@ ${htmlImgs.join(`\n`)}
|
|
53 |
description: descriptionMd,
|
54 |
});
|
55 |
const paramsStr = params.toString();
|
56 |
-
window.open(`https://huggingface.co/spaces/
|
57 |
shareBtnEl.style.removeProperty('pointer-events');
|
58 |
shareIconEl.style.removeProperty('display');
|
59 |
loadingIconEl.style.display = 'none';
|
|
|
53 |
description: descriptionMd,
|
54 |
});
|
55 |
const paramsStr = params.toString();
|
56 |
+
window.open(`https://huggingface.co/spaces/BAAI/bilingual_stable_diffusion/discussions/new?${paramsStr}`, '_blank');
|
57 |
shareBtnEl.style.removeProperty('pointer-events');
|
58 |
shareIconEl.style.removeProperty('display');
|
59 |
loadingIconEl.style.display = 'none';
|