Spaces:
Running
Running
Commit
·
303ab61
1
Parent(s):
5f54907
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,28 +23,10 @@ def getTextTrans(text, source='zh', target='en'):
|
|
| 23 |
|
| 24 |
extend_prompt_pipe = pipeline('text-generation', model='yizhangliu/prompt-extend', max_length=77, pad_token_id=0)
|
| 25 |
|
| 26 |
-
examples = [
|
| 27 |
-
['elon musk as thor'],
|
| 28 |
-
["giant dragon flying in the sky"],
|
| 29 |
-
['psychedelic liquids space'],
|
| 30 |
-
["a coconut laying on the beach"],
|
| 31 |
-
["peaceful village landscape"],
|
| 32 |
-
]
|
| 33 |
-
|
| 34 |
-
# model_ids = {
|
| 35 |
-
# # "models/stabilityai/stable-diffusion-2-1":"sd-v2-1",
|
| 36 |
-
# "models/stabilityai/stable-diffusion-2":"sd-v2-0",
|
| 37 |
-
# # "models/runwayml/stable-diffusion-v1-5":"sd-v1-5",
|
| 38 |
-
# # "models/CompVis/stable-diffusion-v1-4":"sd-v1-4",
|
| 39 |
-
# "models/prompthero/openjourney":"openjourney",
|
| 40 |
-
# "models/hakurei/waifu-diffusion":"waifu-diffusion",
|
| 41 |
-
# "models/Linaqruf/anything-v3.0":"anything-v3.0",
|
| 42 |
-
# }
|
| 43 |
-
|
| 44 |
space_ids = {
|
| 45 |
"spaces/stabilityai/stable-diffusion":"Stable Diffusion 2.1",
|
|
|
|
| 46 |
"spaces/stabilityai/stable-diffusion-1":"Stable Diffusion 1.0",
|
| 47 |
-
# "spaces/hakurei/waifu-diffusion-demo":"waifu-diffusion",
|
| 48 |
}
|
| 49 |
|
| 50 |
tab_actions = []
|
|
@@ -104,14 +86,14 @@ start_work = """async() => {
|
|
| 104 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 105 |
|
| 106 |
for (var i = 0; i < tabitems.length; i++) {
|
| 107 |
-
if ([0, 1].includes(i)) {
|
| 108 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
| 109 |
for (var j = 0; j < tabitems[i].childNodes[0].children[1].children.length; j++) {
|
| 110 |
if (j != 1) {
|
| 111 |
tabitems[i].childNodes[0].children[1].children[j].style.display='none';
|
| 112 |
}
|
| 113 |
}
|
| 114 |
-
} else
|
| 115 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
| 116 |
tabitems[i].childNodes[0].children[1].style.display='none';
|
| 117 |
tabitems[i].childNodes[0].children[2].children[0].style.display='none';
|
|
@@ -140,9 +122,9 @@ start_work = """async() => {
|
|
| 140 |
window['prevPrompt'] = text_value;
|
| 141 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 142 |
for (var i = 0; i < tabitems.length; i++) {
|
| 143 |
-
if ([0, 1].includes(i)) {
|
| 144 |
inputText = tabitems[i].children[0].children[1].children[0].querySelectorAll('.gr-text-input')[0];
|
| 145 |
-
} else
|
| 146 |
inputText = tabitems[i].childNodes[0].children[2].children[0].children[0].querySelectorAll('.gr-text-input')[0];
|
| 147 |
}
|
| 148 |
setNativeValue(inputText, text_value);
|
|
@@ -209,14 +191,13 @@ with gr.Blocks(title='Text-to-Image') as demo:
|
|
| 209 |
prompt_input1 = gr.Textbox(lines=2, label="Extend prompt", visible=True)
|
| 210 |
draw_btn_1 = gr.Button(value = "Generate(extend)", elem_id="draw-btn-1")
|
| 211 |
prompt_work = gr.Textbox(lines=1, label="prompt_work", elem_id="prompt_work", visible=False)
|
| 212 |
-
extend_btn.click(fn=prompt_extend, inputs=[prompt_input0], outputs=[prompt_input1])
|
| 213 |
-
draw_btn_0.click(fn=prompt_draw, inputs=[prompt_input0], outputs=[prompt_work])
|
| 214 |
-
draw_btn_1.click(fn=prompt_draw, inputs=[prompt_input1], outputs=[prompt_work])
|
| 215 |
with gr.Row(elem_id='tab_demo', visible=True).style(height=200):
|
| 216 |
tab_demo = gr.TabbedInterface(tab_actions, tab_titles)
|
| 217 |
with gr.Row():
|
| 218 |
gr.HTML(f"<p>{thanks_info}</p>")
|
| 219 |
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
| 222 |
demo.launch()
|
|
|
|
| 23 |
|
| 24 |
extend_prompt_pipe = pipeline('text-generation', model='yizhangliu/prompt-extend', max_length=77, pad_token_id=0)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
space_ids = {
|
| 27 |
"spaces/stabilityai/stable-diffusion":"Stable Diffusion 2.1",
|
| 28 |
+
"spaces/runwayml/stable-diffusion-v1-5":"Stable Diffusion 1.5",
|
| 29 |
"spaces/stabilityai/stable-diffusion-1":"Stable Diffusion 1.0",
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
tab_actions = []
|
|
|
|
| 86 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 87 |
|
| 88 |
for (var i = 0; i < tabitems.length; i++) {
|
| 89 |
+
if ([0, 1, 2].includes(i)) {
|
| 90 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
| 91 |
for (var j = 0; j < tabitems[i].childNodes[0].children[1].children.length; j++) {
|
| 92 |
if (j != 1) {
|
| 93 |
tabitems[i].childNodes[0].children[1].children[j].style.display='none';
|
| 94 |
}
|
| 95 |
}
|
| 96 |
+
} else {
|
| 97 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
| 98 |
tabitems[i].childNodes[0].children[1].style.display='none';
|
| 99 |
tabitems[i].childNodes[0].children[2].children[0].style.display='none';
|
|
|
|
| 122 |
window['prevPrompt'] = text_value;
|
| 123 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 124 |
for (var i = 0; i < tabitems.length; i++) {
|
| 125 |
+
if ([0, 1, 2].includes(i)) {
|
| 126 |
inputText = tabitems[i].children[0].children[1].children[0].querySelectorAll('.gr-text-input')[0];
|
| 127 |
+
} else {
|
| 128 |
inputText = tabitems[i].childNodes[0].children[2].children[0].children[0].querySelectorAll('.gr-text-input')[0];
|
| 129 |
}
|
| 130 |
setNativeValue(inputText, text_value);
|
|
|
|
| 191 |
prompt_input1 = gr.Textbox(lines=2, label="Extend prompt", visible=True)
|
| 192 |
draw_btn_1 = gr.Button(value = "Generate(extend)", elem_id="draw-btn-1")
|
| 193 |
prompt_work = gr.Textbox(lines=1, label="prompt_work", elem_id="prompt_work", visible=False)
|
|
|
|
|
|
|
|
|
|
| 194 |
with gr.Row(elem_id='tab_demo', visible=True).style(height=200):
|
| 195 |
tab_demo = gr.TabbedInterface(tab_actions, tab_titles)
|
| 196 |
with gr.Row():
|
| 197 |
gr.HTML(f"<p>{thanks_info}</p>")
|
| 198 |
|
| 199 |
+
extend_btn.click(fn=prompt_extend, inputs=[prompt_input0], outputs=[prompt_input1])
|
| 200 |
+
draw_btn_0.click(fn=prompt_draw, inputs=[prompt_input0], outputs=[prompt_work])
|
| 201 |
+
draw_btn_1.click(fn=prompt_draw, inputs=[prompt_input1], outputs=[prompt_work])
|
| 202 |
+
|
| 203 |
demo.launch()
|