Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,6 @@ import requests.exceptions
|
|
7 |
from huggingface_hub import HfApi, hf_hub_download
|
8 |
from huggingface_hub.repocard import metadata_load
|
9 |
|
10 |
-
|
11 |
app = gr.Blocks()
|
12 |
|
13 |
model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
|
@@ -16,7 +15,6 @@ model_id_3 = "distilbert-base-uncased-finetuned-sst-2-english"
|
|
16 |
model_id_4 = "lordtt13/emo-mobilebert"
|
17 |
model_id_5 = "juliensimon/reviews-sentiment-analysis"
|
18 |
|
19 |
-
|
20 |
def get_prediction(model_id):
|
21 |
|
22 |
classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
|
@@ -27,7 +25,6 @@ def get_prediction(model_id):
|
|
27 |
return prediction
|
28 |
return predict
|
29 |
|
30 |
-
|
31 |
with app:
|
32 |
gr.Markdown(
|
33 |
"""
|
@@ -44,15 +41,43 @@ with app:
|
|
44 |
""")
|
45 |
with gr.Row():
|
46 |
with gr.Column():
|
47 |
-
|
|
|
|
|
|
|
48 |
btn1 = gr.Button("Predict - Model 1")
|
49 |
-
|
|
|
|
|
|
|
50 |
btn2 = gr.Button("Predict - Model 2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
with gr.Column():
|
52 |
out_1 = gr.Textbox(label="Predictions for Model 1")
|
53 |
-
out_2 = gr.Textbox(label="Predictions for Model 2")
|
|
|
|
|
|
|
|
|
54 |
btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
|
55 |
btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
|
56 |
-
|
|
|
|
|
57 |
|
58 |
app.launch()
|
|
|
7 |
from huggingface_hub import HfApi, hf_hub_download
|
8 |
from huggingface_hub.repocard import metadata_load
|
9 |
|
|
|
10 |
app = gr.Blocks()
|
11 |
|
12 |
model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
|
|
|
15 |
model_id_4 = "lordtt13/emo-mobilebert"
|
16 |
model_id_5 = "juliensimon/reviews-sentiment-analysis"
|
17 |
|
|
|
18 |
def get_prediction(model_id):
|
19 |
|
20 |
classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
|
|
|
25 |
return prediction
|
26 |
return predict
|
27 |
|
|
|
28 |
with app:
|
29 |
gr.Markdown(
|
30 |
"""
|
|
|
41 |
""")
|
42 |
with gr.Row():
|
43 |
with gr.Column():
|
44 |
+
gr.Markdown(
|
45 |
+
"""
|
46 |
+
Model 1 = nlptown/bert-base-multilingual-uncased-sentiment
|
47 |
+
""")
|
48 |
btn1 = gr.Button("Predict - Model 1")
|
49 |
+
gr.Markdown(
|
50 |
+
"""
|
51 |
+
Model 2 = microsoft/deberta-base
|
52 |
+
""")
|
53 |
btn2 = gr.Button("Predict - Model 2")
|
54 |
+
gr.Markdown(
|
55 |
+
"""
|
56 |
+
Model 3 = distilbert-base-uncased-finetuned-sst-2-english"
|
57 |
+
""")
|
58 |
+
btn3 = gr.Button("Predict - Model 3")
|
59 |
+
gr.Markdown(
|
60 |
+
"""
|
61 |
+
Model 4 = lordtt13/emo-mobilebert
|
62 |
+
""")
|
63 |
+
btn4 = gr.Button("Predict - Model 4")
|
64 |
+
gr.Markdown(
|
65 |
+
"""
|
66 |
+
Model 5 = juliensimon/reviews-sentiment-analysis
|
67 |
+
""")
|
68 |
+
btn5 = gr.Button("Predict - Model 5")
|
69 |
+
|
70 |
with gr.Column():
|
71 |
out_1 = gr.Textbox(label="Predictions for Model 1")
|
72 |
+
out_2 = gr.Textbox(label="Predictions for Model 2")
|
73 |
+
out_3 = gr.Textbox(label="Predictions for Model 3")
|
74 |
+
out_4 = gr.Textbox(label="Predictions for Model 4")
|
75 |
+
out_5 = gr.Textbox(label="Predictions for Model 5")
|
76 |
+
|
77 |
btn1.click(fn=get_prediction(model_id_1), inputs=inp_1, outputs=out_1)
|
78 |
btn2.click(fn=get_prediction(model_id_2), inputs=inp_1, outputs=out_2)
|
79 |
+
btn3.click(fn=get_prediction(model_id_3), inputs=inp_1, outputs=out_3)
|
80 |
+
btn4.click(fn=get_prediction(model_id_4), inputs=inp_1, outputs=out_4)
|
81 |
+
btn5.click(fn=get_prediction(model_id_5), inputs=inp_1, outputs=out_5)
|
82 |
|
83 |
app.launch()
|