File size: 1,125 Bytes
5e6183c
 
a49337e
5e6183c
a49337e
 
d03353e
a49337e
 
 
03420da
 
a49337e
 
 
 
 
 
 
 
 
 
 
 
03420da
a49337e
 
 
 
 
 
 
 
 
 
 
 
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

from generic import generate_visual

def generate_viz(text, target_class):
    
    print(f"Input Text: {text}")
    print(f"Target Class: {target_class}")
    text_batch=[]
    text_batch.append(text)
    token_import, html_page = generate_visual(text_batch=text_batch, target_class=target_class)
    return token_import, html_page

title = "Explain BERT πŸ˜„"


iface = gr.Interface(fn=generate_viz, inputs=[
        gr.Text(label="Input Text"),
        gr.Dropdown(
            [0,1],
            label="Target_Class",
            info="0 is negative, 1 is positive",
        ),
    ],
    outputs=[ gr.Text(label="Token_Importance"), gr.HTML(label="visualize sentence"),],
    title=title,
    allow_flagging="never",
    cache_examples=True,
    examples=[
        ["This movie was the best movie I have ever seen! some scenes were ridiculous, but acting was great.", 1],
        ["I really didn't like this movie. Some of the actors were good, but overall the movie was boring.", 0],
        ["I hate that I love you.", 0],
        ["I hate that I love you.", 1],
    ],
)

iface.launch(debug=True)