Spaces:
Sleeping
Sleeping
Update the app layout with Blocks
Browse files
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
|
10 |
ret = predict_mainidea_sent(essay, model), predict_mainidea_sent_old(essay, model)
|
11 |
return ret
|
12 |
|
13 |
-
|
14 |
-
gr.
|
15 |
-
label="
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|