Commit
·
90b5e3c
1
Parent(s):
307634f
update
Browse files
app.py
CHANGED
|
@@ -1,9 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
def
|
| 4 |
return f"Title:{title}\nContext:{context}\n..."
|
| 5 |
|
| 6 |
-
def
|
|
|
|
|
|
|
|
|
|
| 7 |
return f"Title:{title}\nContext:{context}\n...{img}"
|
| 8 |
|
| 9 |
with gr.Blocks() as demo:
|
|
@@ -12,8 +15,8 @@ with gr.Blocks() as demo:
|
|
| 12 |
# 多个tab
|
| 13 |
with gr.Tabs():
|
| 14 |
|
| 15 |
-
with gr.TabItem("E-FB15k237"
|
| 16 |
-
|
| 17 |
origin_button = gr.Button("Origin")
|
| 18 |
origin_output = gr.Textbox(label="Before Edit", lines=2, placeholder="")
|
| 19 |
|
|
@@ -21,6 +24,13 @@ with gr.Blocks() as demo:
|
|
| 21 |
edit_button = gr.Button("Edit", elem_id="warning")
|
| 22 |
|
| 23 |
edit_output = gr.Textbox(label="After Edit", lines=2, placeholder="")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
with gr.TabItem("A-FB15k237"):
|
| 26 |
title = gr.Textbox(label="Input", lines=1, placeholder="New triple input")
|
|
@@ -31,7 +41,8 @@ with gr.Blocks() as demo:
|
|
| 31 |
add_output = gr.Textbox(label="Add Results", lines=2, placeholder="")
|
| 32 |
|
| 33 |
|
| 34 |
-
edit_button.click(fn=
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
def origin_preditcion(title, context):
|
| 4 |
return f"Title:{title}\nContext:{context}\n..."
|
| 5 |
|
| 6 |
+
def edit_process(title, context):
|
| 7 |
+
return f"Title:{title}\nContext:{context}\n..."
|
| 8 |
+
|
| 9 |
+
def add_process(title, context, img):
|
| 10 |
return f"Title:{title}\nContext:{context}\n...{img}"
|
| 11 |
|
| 12 |
with gr.Blocks() as demo:
|
|
|
|
| 15 |
# 多个tab
|
| 16 |
with gr.Tabs():
|
| 17 |
|
| 18 |
+
with gr.TabItem("E-FB15k237"):
|
| 19 |
+
input = gr.Textbox(label="Input", lines=1, placeholder="Mask triple input")
|
| 20 |
origin_button = gr.Button("Origin")
|
| 21 |
origin_output = gr.Textbox(label="Before Edit", lines=2, placeholder="")
|
| 22 |
|
|
|
|
| 24 |
edit_button = gr.Button("Edit", elem_id="warning")
|
| 25 |
|
| 26 |
edit_output = gr.Textbox(label="After Edit", lines=2, placeholder="")
|
| 27 |
+
gr.Examples(
|
| 28 |
+
examples=["[MASK] r t", "h"],
|
| 29 |
+
inputs=[input, alter_label],
|
| 30 |
+
outputs=edit_output,
|
| 31 |
+
fn=edit_process,
|
| 32 |
+
cache_examples=True,
|
| 33 |
+
)
|
| 34 |
|
| 35 |
with gr.TabItem("A-FB15k237"):
|
| 36 |
title = gr.Textbox(label="Input", lines=1, placeholder="New triple input")
|
|
|
|
| 41 |
add_output = gr.Textbox(label="Add Results", lines=2, placeholder="")
|
| 42 |
|
| 43 |
|
| 44 |
+
edit_button.click(fn=edit_process, inputs=[title, alter_label], outputs=edit_output)
|
| 45 |
+
origin_button.click(fn=origin_preditcion, inputs=[title, alter_label], outputs=edit_output)
|
| 46 |
+
add_button.click(fn=add_process, inputs=[title, alter_label], outputs=add_output)
|
| 47 |
|
| 48 |
demo.launch()
|