Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,18 +104,33 @@ css = """
|
|
| 104 |
"""
|
| 105 |
|
| 106 |
with gr.Blocks(css=css) as demo:
|
| 107 |
-
gr.Markdown("Test")
|
| 108 |
-
|
|
|
|
| 109 |
with gr.Row():
|
| 110 |
-
|
| 111 |
-
|
|
|
|
|
|
|
| 112 |
text_input = gr.Textbox(label="Text Prompt")
|
| 113 |
-
submit_btn = gr.Button(
|
| 114 |
-
|
|
|
|
|
|
|
| 115 |
output_text = gr.Textbox(label="Output Text")
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
demo.launch(debug=False)
|
| 120 |
|
| 121 |
|
|
|
|
| 104 |
"""
|
| 105 |
|
| 106 |
with gr.Blocks(css=css) as demo:
|
| 107 |
+
gr.Markdown("## Test")
|
| 108 |
+
|
| 109 |
+
with gr.Tab("Input"):
|
| 110 |
with gr.Row():
|
| 111 |
+
|
| 112 |
+
# --- 左列:输入 ---
|
| 113 |
+
with gr.Column(scale=1, min_width=300):
|
| 114 |
+
input_img = gr.Image(label="Input Picture", type="pil")
|
| 115 |
text_input = gr.Textbox(label="Text Prompt")
|
| 116 |
+
submit_btn = gr.Button("Submit")
|
| 117 |
+
|
| 118 |
+
# --- 右列:输出 ---
|
| 119 |
+
with gr.Column(scale=1, min_width=300):
|
| 120 |
output_text = gr.Textbox(label="Output Text")
|
| 121 |
+
|
| 122 |
+
# 事件绑定
|
| 123 |
+
submit_btn.click(
|
| 124 |
+
fn=run_example,
|
| 125 |
+
inputs=[input_img, text_input],
|
| 126 |
+
outputs=output_text, # 只一个时可直写对象
|
| 127 |
+
queue=True # 推荐写在 click 而非全局 queue()
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
# 若想全局排队,也可注释上方 `queue=True` 把这两行放外面:
|
| 131 |
+
# demo.queue() # 开启排队
|
| 132 |
+
# demo.launch() # 启动
|
| 133 |
+
|
| 134 |
demo.launch(debug=False)
|
| 135 |
|
| 136 |
|