File size: 974 Bytes
134e623
ecf6936
 
 
134e623
ecf6936
 
134e623
ecf6936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134e623
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
import gradio as gr
from transformers import AutoModel, AutoConfig
from main_idea_with_torch import predict_mainidea_sent_old
from main_idea_with_pipeline import predict_mainidea_sent

config = AutoConfig.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True)
model = AutoModel.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True, config=config)

def greet(essay):
    ret = predict_mainidea_sent(essay, model), predict_mainidea_sent_old(essay, model)
    return ret

iface = gr.Interface(fn=greet, inputs="text", outputs=[
    gr.Dataframe(
        label="pipeline output",
        headers=['label: is main idea', 'sentence'],
        datatype=["str", "str"],
        col_count=(2, "fixed"),
    ),
    gr.Dataframe(
        label="torch output with Triage",
        headers=['label: is main idea', 'sentence'],
        datatype=["str", "str"],
        col_count=(2, "fixed"),
    )
])
iface.launch()