Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,58 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
# 首先加载模型但不要立即launch
|
| 4 |
model = gr.load("models/black-forest-labs/FLUX.1-schnell")
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
model.render()
|
| 10 |
|
| 11 |
-
# 添加JavaScript
|
| 12 |
gr.Markdown("""
|
|
|
|
| 13 |
<script>
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
}
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
</script>
|
| 24 |
-
"""
|
| 25 |
|
| 26 |
# 添加底部文案和链接
|
| 27 |
-
with gr.Row():
|
| 28 |
gr.Markdown("""
|
| 29 |
**Best AI Tools**
|
| 30 |
[Nude AI](https://nudeai.beauty) • [Uncensored AI](https://uncensoredai.cc) • [AI Hentai Generator](https://aihentaigenerator.fun) • [Stable Diffusion Hentai](https://stable-diffusion-hentai.aihentaigenerator.fun) • [Bing Image Creator](https://bingimagecreator.online) • [NSFW AI Art](https://nsfwaiart.art) • [NSFW AI Chatbot](https://nsfw-ai-chatbot.online) • [NSFW AI World](https://nsfwai.world) • [AI Tools Directory](https://aitoolsdirectory.online) • [Viggle AI](https://viggleai.live) • [TDEE Calculator](https://tdeecalculator.online) • [Calculator App](https://calculatorapp.online) • [Compound Interest Calculator](https://compoundinterestcalculator.site) • [AI Story Generator](https://aistorygenerator.fun) • [Llama AI](https://llamaai.online) • [AI Art Free](https://aiartfree.online) • [Cek Khodam](https://cekkhodam.co) • [AI Detector](https://ai-detector.online) • [AI Cover](https://aicover.fun) • [Flux AI](https://flux-ai.online) • [Brat Generator](https://bratgenerator.org) • [AI Text Generator](https://aitextgenerator.live) • [Black Myth Wukong](https://blackmythwukong.buzz) • [Book Summary](https://booksummary.wiki) • [ChatGPT Gratuit](https://chatgptgratuit.chat) • [ChatGPT Online](https://chatgtponline.com) • [Gau Thai](https://gauthai.pro) • [Best Recipe](https://bestrecipe.pro)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
model = gr.load("models/black-forest-labs/FLUX.1-schnell")
|
| 4 |
|
| 5 |
+
with gr.Blocks(css="""
|
| 6 |
+
.debug-info {
|
| 7 |
+
display: none;
|
| 8 |
+
padding: 10px;
|
| 9 |
+
background: #f0f0f0;
|
| 10 |
+
margin: 10px 0;
|
| 11 |
+
}
|
| 12 |
+
""") as demo:
|
| 13 |
model.render()
|
| 14 |
|
| 15 |
+
# 添加JavaScript来设置默认值并调试界面结构
|
| 16 |
gr.Markdown("""
|
| 17 |
+
<div class="debug-info" id="debug-info"></div>
|
| 18 |
<script>
|
| 19 |
+
function setDefaultText() {
|
| 20 |
+
// 尝试不同的选择器来定位输入框
|
| 21 |
+
const textareas = document.querySelectorAll('textarea');
|
| 22 |
+
const inputs = document.querySelectorAll('input[type="text"]');
|
| 23 |
+
const debugInfo = document.getElementById('debug-info');
|
| 24 |
+
|
| 25 |
+
// 调试信息
|
| 26 |
+
let info = `找到 ${textareas.length} 个textarea和 ${inputs.length} 个text input\n`;
|
| 27 |
+
|
| 28 |
+
// 尝试设置每个文本框的值
|
| 29 |
+
textareas.forEach((textarea, index) => {
|
| 30 |
+
info += `Textarea ${index}: ${textarea.className}\n`;
|
| 31 |
+
textarea.value = "Hi! Create a image.";
|
| 32 |
+
// 触发input事件以确保Gradio检测到变化
|
| 33 |
+
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
| 34 |
+
});
|
| 35 |
+
|
| 36 |
+
inputs.forEach((input, index) => {
|
| 37 |
+
info += `Input ${index}: ${input.className}\n`;
|
| 38 |
+
input.value = "Hi! Create a image.";
|
| 39 |
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
| 40 |
+
});
|
| 41 |
+
|
| 42 |
+
debugInfo.textContent = info;
|
| 43 |
+
debugInfo.style.display = 'block'; // 显示调试信息
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
// 等待一段时间后执行
|
| 47 |
+
setTimeout(() => {
|
| 48 |
+
setDefaultText();
|
| 49 |
+
// 如果第一次不成功,再试一次
|
| 50 |
+
setTimeout(setDefaultText, 1000);
|
| 51 |
+
}, 2000);
|
| 52 |
</script>
|
| 53 |
+
""")
|
| 54 |
|
| 55 |
# 添加底部文案和链接
|
|
|
|
| 56 |
gr.Markdown("""
|
| 57 |
**Best AI Tools**
|
| 58 |
[Nude AI](https://nudeai.beauty) • [Uncensored AI](https://uncensoredai.cc) • [AI Hentai Generator](https://aihentaigenerator.fun) • [Stable Diffusion Hentai](https://stable-diffusion-hentai.aihentaigenerator.fun) • [Bing Image Creator](https://bingimagecreator.online) • [NSFW AI Art](https://nsfwaiart.art) • [NSFW AI Chatbot](https://nsfw-ai-chatbot.online) • [NSFW AI World](https://nsfwai.world) • [AI Tools Directory](https://aitoolsdirectory.online) • [Viggle AI](https://viggleai.live) • [TDEE Calculator](https://tdeecalculator.online) • [Calculator App](https://calculatorapp.online) • [Compound Interest Calculator](https://compoundinterestcalculator.site) • [AI Story Generator](https://aistorygenerator.fun) • [Llama AI](https://llamaai.online) • [AI Art Free](https://aiartfree.online) • [Cek Khodam](https://cekkhodam.co) • [AI Detector](https://ai-detector.online) • [AI Cover](https://aicover.fun) • [Flux AI](https://flux-ai.online) • [Brat Generator](https://bratgenerator.org) • [AI Text Generator](https://aitextgenerator.live) • [Black Myth Wukong](https://blackmythwukong.buzz) • [Book Summary](https://booksummary.wiki) • [ChatGPT Gratuit](https://chatgptgratuit.chat) • [ChatGPT Online](https://chatgtponline.com) • [Gau Thai](https://gauthai.pro) • [Best Recipe](https://bestrecipe.pro)
|