yutingg commited on
Commit
cec7d5e
1 Parent(s): ecf6936

Update the app layout with Blocks

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -6,22 +6,30 @@ from main_idea_with_pipeline import predict_mainidea_sent
6
  config = AutoConfig.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True)
7
  model = AutoModel.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True, config=config)
8
 
9
- def greet(essay):
10
  ret = predict_mainidea_sent(essay, model), predict_mainidea_sent_old(essay, model)
11
  return ret
12
 
13
- iface = gr.Interface(fn=greet, inputs="text", outputs=[
14
- gr.Dataframe(
15
- label="pipeline output",
16
- headers=['label: is main idea', 'sentence'],
17
- datatype=["str", "str"],
18
- col_count=(2, "fixed"),
19
- ),
20
- gr.Dataframe(
21
- label="torch output with Triage",
22
- headers=['label: is main idea', 'sentence'],
23
- datatype=["str", "str"],
24
- col_count=(2, "fixed"),
25
- )
26
- ])
27
- iface.launch()
 
 
 
 
 
 
 
 
 
6
  config = AutoConfig.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True)
7
  model = AutoModel.from_pretrained("yutingg/custom-distill-bert-for-sentence-label", trust_remote_code=True, config=config)
8
 
9
+ def predict_main_idea(essay):
10
  ret = predict_mainidea_sent(essay, model), predict_mainidea_sent_old(essay, model)
11
  return ret
12
 
13
+ with gr.Blocks() as main_idea_demo:
14
+ with gr.Row():
15
+ essay_input = gr.Textbox(label="essay", lines=10)
16
+ with gr.Row():
17
+ predict_button = gr.Button("Predict Main Idea Sentence")
18
+ with gr.Row():
19
+ with gr.Column(scale=1, min_width=600):
20
+ output_1 = gr.Dataframe(
21
+ label="pipeline output",
22
+ headers=['label: is main idea', 'sentence'],
23
+ datatype=["str", "str"],
24
+ col_count=(2, "fixed"),
25
+ )
26
+ with gr.Column(scale=1, min_width=600):
27
+ output_2 = gr.Dataframe(
28
+ label="torch output with Triage",
29
+ headers=['label: is main idea', 'sentence'],
30
+ datatype=["str", "str"],
31
+ col_count=(2, "fixed"),
32
+ )
33
+ predict_button.click(predict_main_idea, inputs=essay_input, outputs=[output_1, output_2])
34
+
35
+ main_idea_demo.launch()