Spaces:
Running
Running
Commit
·
499dfda
1
Parent(s):
e0c32c9
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,6 +28,7 @@ space_ids = {
|
|
| 28 |
"spaces/stabilityai/stable-diffusion": "SD 2.1",
|
| 29 |
"spaces/runwayml/stable-diffusion-v1-5": "SD 1.5",
|
| 30 |
"spaces/stabilityai/stable-diffusion-1": "SD 1.0",
|
|
|
|
| 31 |
"spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese": "Taiyi(太乙)",
|
| 32 |
}
|
| 33 |
|
|
@@ -88,10 +89,15 @@ if do_dreamlike_photoreal:
|
|
| 88 |
for space_id in space_ids.keys():
|
| 89 |
print(space_id, space_ids[space_id])
|
| 90 |
try:
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
except Exception as e:
|
| 96 |
logger.info(f"load_fail__{space_id}_{e}")
|
| 97 |
|
|
@@ -125,7 +131,6 @@ start_work = """async() => {
|
|
| 125 |
valueSetter.call(element, value);
|
| 126 |
}
|
| 127 |
}
|
| 128 |
-
|
| 129 |
window['tab_advanced'] = 0;
|
| 130 |
|
| 131 |
var gradioEl = document.querySelector('body > gradio-app').shadowRoot;
|
|
@@ -135,10 +140,10 @@ start_work = """async() => {
|
|
| 135 |
|
| 136 |
if (typeof window['gradioEl'] === 'undefined') {
|
| 137 |
window['gradioEl'] = gradioEl;
|
| 138 |
-
|
| 139 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 140 |
tabitems_title = window['gradioEl'].querySelectorAll('#tab_demo')[0].children[0].children[0].children;
|
| 141 |
-
|
|
|
|
| 142 |
for (var i = 0; i < tabitems.length; i++) {
|
| 143 |
if (tabitems_title[i].innerText.indexOf('SD') >= 0) {
|
| 144 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
|
@@ -159,6 +164,8 @@ start_work = """async() => {
|
|
| 159 |
tabitems[i].children[0].children[0].children[0].children[0].children[1].style.display='none';
|
| 160 |
} else if (tabitems_title[i].innerText.indexOf('Dreamlike') >= 0) {
|
| 161 |
tabitems[i].childNodes[0].children[0].children[1].style.display='none';
|
|
|
|
|
|
|
| 162 |
}
|
| 163 |
}
|
| 164 |
|
|
@@ -175,7 +182,6 @@ start_work = """async() => {
|
|
| 175 |
}
|
| 176 |
page1.style.display = "none";
|
| 177 |
page2.style.display = "block";
|
| 178 |
-
|
| 179 |
prompt_work = window['gradioEl'].querySelectorAll('#prompt_work');
|
| 180 |
for (var i = 0; i < prompt_work.length; i++) {
|
| 181 |
prompt_work[i].style.display='none';
|
|
@@ -198,6 +204,20 @@ start_work = """async() => {
|
|
| 198 |
window['prevPrompt'] = text_value;
|
| 199 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 200 |
for (var i = 0; i < tabitems.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
inputText = null;
|
| 202 |
if (tabitems_title[i].innerText.indexOf('SD') >= 0) {
|
| 203 |
text_value = window['gradioEl'].querySelectorAll('#prompt_work')[0].querySelectorAll('textarea')[0].value;
|
|
@@ -209,7 +229,7 @@ start_work = """async() => {
|
|
| 209 |
if (inputText) {
|
| 210 |
setNativeValue(inputText, text_value);
|
| 211 |
inputText.dispatchEvent(new Event('input', { bubbles: true }));
|
| 212 |
-
}
|
| 213 |
}
|
| 214 |
|
| 215 |
setTimeout(function() {
|
|
@@ -366,5 +386,6 @@ with gr.Blocks(title='Text-to-Image') as demo:
|
|
| 366 |
else:
|
| 367 |
draw_btn_0.click(fn=prompt_draw_2, inputs=[prompt_input0], outputs=[prompt_work, prompt_work_zh])
|
| 368 |
draw_btn_1.click(fn=prompt_draw_2, inputs=[prompt_input1], outputs=[prompt_work, prompt_work_zh])
|
| 369 |
-
|
|
|
|
| 370 |
demo.launch()
|
|
|
|
| 28 |
"spaces/stabilityai/stable-diffusion": "SD 2.1",
|
| 29 |
"spaces/runwayml/stable-diffusion-v1-5": "SD 1.5",
|
| 30 |
"spaces/stabilityai/stable-diffusion-1": "SD 1.0",
|
| 31 |
+
"dalle_mini_tab": "Dalle mini",
|
| 32 |
"spaces/IDEA-CCNL/Taiyi-Stable-Diffusion-Chinese": "Taiyi(太乙)",
|
| 33 |
}
|
| 34 |
|
|
|
|
| 89 |
for space_id in space_ids.keys():
|
| 90 |
print(space_id, space_ids[space_id])
|
| 91 |
try:
|
| 92 |
+
tab_title = space_ids[space_id]
|
| 93 |
+
tab_titles.append(tab_title)
|
| 94 |
+
if (tab_title == 'Dalle mini'):
|
| 95 |
+
tab_content = gr.Blocks(elem_id='dalle_mini')
|
| 96 |
+
tab_actions.append(tab_content)
|
| 97 |
+
else:
|
| 98 |
+
tab_content = gr.Interface.load(space_id)
|
| 99 |
+
tab_actions.append(tab_content)
|
| 100 |
+
thanks_info += f"[<a style='display:inline-block' href='https://huggingface.co/{space_id}' _blank><font style='color:blue;weight:bold;'>{tab_title}</font></a>]"
|
| 101 |
except Exception as e:
|
| 102 |
logger.info(f"load_fail__{space_id}_{e}")
|
| 103 |
|
|
|
|
| 131 |
valueSetter.call(element, value);
|
| 132 |
}
|
| 133 |
}
|
|
|
|
| 134 |
window['tab_advanced'] = 0;
|
| 135 |
|
| 136 |
var gradioEl = document.querySelector('body > gradio-app').shadowRoot;
|
|
|
|
| 140 |
|
| 141 |
if (typeof window['gradioEl'] === 'undefined') {
|
| 142 |
window['gradioEl'] = gradioEl;
|
|
|
|
| 143 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 144 |
tabitems_title = window['gradioEl'].querySelectorAll('#tab_demo')[0].children[0].children[0].children;
|
| 145 |
+
window['dalle_mini_block'] = null;
|
| 146 |
+
window['dalle_mini_iframe'] = null;
|
| 147 |
for (var i = 0; i < tabitems.length; i++) {
|
| 148 |
if (tabitems_title[i].innerText.indexOf('SD') >= 0) {
|
| 149 |
tabitems[i].childNodes[0].children[0].style.display='none';
|
|
|
|
| 164 |
tabitems[i].children[0].children[0].children[0].children[0].children[1].style.display='none';
|
| 165 |
} else if (tabitems_title[i].innerText.indexOf('Dreamlike') >= 0) {
|
| 166 |
tabitems[i].childNodes[0].children[0].children[1].style.display='none';
|
| 167 |
+
} else if (tabitems_title[i].innerText.indexOf('Dalle mini') >= 0) {
|
| 168 |
+
window['dalle_mini_block']= tabitems[i];
|
| 169 |
}
|
| 170 |
}
|
| 171 |
|
|
|
|
| 182 |
}
|
| 183 |
page1.style.display = "none";
|
| 184 |
page2.style.display = "block";
|
|
|
|
| 185 |
prompt_work = window['gradioEl'].querySelectorAll('#prompt_work');
|
| 186 |
for (var i = 0; i < prompt_work.length; i++) {
|
| 187 |
prompt_work[i].style.display='none';
|
|
|
|
| 204 |
window['prevPrompt'] = text_value;
|
| 205 |
tabitems = window['gradioEl'].querySelectorAll('.tabitem');
|
| 206 |
for (var i = 0; i < tabitems.length; i++) {
|
| 207 |
+
if (tabitems_title[i].innerText.indexOf('Dalle mini') >= 0) {
|
| 208 |
+
if (window['dalle_mini_block']) {
|
| 209 |
+
if (window['dalle_mini_iframe'] === null) {
|
| 210 |
+
window['dalle_mini_iframe'] = document.createElement('iframe');
|
| 211 |
+
window['dalle_mini_iframe'].height = 1000;
|
| 212 |
+
window['dalle_mini_iframe'].width = '100%';
|
| 213 |
+
window['dalle_mini_iframe'].id = 'dalle_iframe';
|
| 214 |
+
window['dalle_mini_block'].appendChild(window['dalle_mini_iframe']);
|
| 215 |
+
}
|
| 216 |
+
window['dalle_mini_iframe'].src = 'https://yizhangliu-dalleclone.hf.space/index.html?prompt=' + encodeURI(text_value);
|
| 217 |
+
console.log('dalle_mini');
|
| 218 |
+
}
|
| 219 |
+
continue;
|
| 220 |
+
}
|
| 221 |
inputText = null;
|
| 222 |
if (tabitems_title[i].innerText.indexOf('SD') >= 0) {
|
| 223 |
text_value = window['gradioEl'].querySelectorAll('#prompt_work')[0].querySelectorAll('textarea')[0].value;
|
|
|
|
| 229 |
if (inputText) {
|
| 230 |
setNativeValue(inputText, text_value);
|
| 231 |
inputText.dispatchEvent(new Event('input', { bubbles: true }));
|
| 232 |
+
}
|
| 233 |
}
|
| 234 |
|
| 235 |
setTimeout(function() {
|
|
|
|
| 386 |
else:
|
| 387 |
draw_btn_0.click(fn=prompt_draw_2, inputs=[prompt_input0], outputs=[prompt_work, prompt_work_zh])
|
| 388 |
draw_btn_1.click(fn=prompt_draw_2, inputs=[prompt_input1], outputs=[prompt_work, prompt_work_zh])
|
| 389 |
+
|
| 390 |
+
demo.queue()
|
| 391 |
demo.launch()
|