File size: 1,352 Bytes
a0a66d7
 
6dd01fc
 
a0a66d7
6dd01fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr

def generate_text(title, context):
    return f"Title:{title}\nContext:{context}\n..."

def generate_mutimodal(title, context, img):
    return f"Title:{title}\nContext:{context}\n...{img}"

with gr.Blocks() as demo:
    gr.Markdown("# KGE Editing")

    # 多个tab
    with gr.Tabs():

        with gr.TabItem("E-FB15k237"):
            title = gr.Textbox(label="Input", lines=1, placeholder="Mask triple input")
            origin_button = gr.Button("Origin")
            origin_output = gr.Textbox(label="Before Edit", lines=2, placeholder="")

            alter_label = gr.Textbox(label="Alter Entity", lines=1, placeholder="Entity Name")            
            edit_button = gr.Button("Edit")

            edit_output = gr.Textbox(label="After Edit", lines=2, placeholder="")

        with gr.TabItem("A-FB15k237"):
            title = gr.Textbox(label="Input", lines=1, placeholder="New triple input")

            alter_label = gr.Textbox(label="Head/Tail", lines=1, placeholder="1:head / 0:tail")
            add_button = gr.Button("Add")

            add_output = gr.Textbox(label="Add Results", lines=2, placeholder="")


    edit_button.click(fn=generate_text, inputs=[title, alter_label], outputs=edit_output)
    add_button.click(fn=generate_mutimodal, inputs=[title, alter_label], outputs=add_output)

demo.launch()