Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
|
2 |
-
# import sklearn
|
3 |
from os import O_ACCMODE
|
4 |
import gradio as gr
|
5 |
import joblib
|
@@ -41,9 +40,10 @@ def get_metadata(model_id):
|
|
41 |
return metadata
|
42 |
except requests.exceptions.HTTPError:
|
43 |
return None
|
|
|
|
|
44 |
|
45 |
-
def predict(review
|
46 |
-
classifier = pipeline("text-classification", model=model_id)
|
47 |
prediction = classifier(review)
|
48 |
print(prediction)
|
49 |
stars = prediction[0]['label']
|
@@ -62,16 +62,18 @@ with app:
|
|
62 |
inp_1= gr.Textbox(label="Type text here.",placeholder="The customer service was satisfactory.")
|
63 |
out_2 = gr.Textbox(label="Prediction")
|
64 |
|
|
|
65 |
gr.Markdown(
|
66 |
"""
|
67 |
Model Predictions
|
68 |
""")
|
69 |
-
|
70 |
with gr.Row():
|
71 |
model1_input = gr.Textbox(label="Model 1")
|
72 |
with gr.Row():
|
73 |
btn = gr.Button("Prediction for Model 1")
|
74 |
-
|
|
|
75 |
|
76 |
|
77 |
|
@@ -79,13 +81,7 @@ with app:
|
|
79 |
model2_input = gr.Textbox(label="Model 2")
|
80 |
with gr.Row():
|
81 |
btn = gr.Button("Prediction for Model 2")
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
# app_button.click(load_agent, inputs=[model1_input, model2_input], outputs=[model1_name, model1_score_output, model2_name, model2_score_output])
|
86 |
-
|
87 |
-
# examples = gr.Examples(examples=[["juliensimon/distilbert-amazon-shoe-reviews","juliensimon/distilbert-amazon-shoe-reviews"]],
|
88 |
-
# inputs=[model1_input, model2_input])
|
89 |
-
|
90 |
|
91 |
app.launch()
|
|
|
1 |
+
import sklearn
|
|
|
2 |
from os import O_ACCMODE
|
3 |
import gradio as gr
|
4 |
import joblib
|
|
|
40 |
return metadata
|
41 |
except requests.exceptions.HTTPError:
|
42 |
return None
|
43 |
+
|
44 |
+
classifier = pipeline("text-classification", model="juliensimon/distilbert-amazon-shoe-reviews")
|
45 |
|
46 |
+
def predict(review):
|
|
|
47 |
prediction = classifier(review)
|
48 |
print(prediction)
|
49 |
stars = prediction[0]['label']
|
|
|
62 |
inp_1= gr.Textbox(label="Type text here.",placeholder="The customer service was satisfactory.")
|
63 |
out_2 = gr.Textbox(label="Prediction")
|
64 |
|
65 |
+
|
66 |
gr.Markdown(
|
67 |
"""
|
68 |
Model Predictions
|
69 |
""")
|
70 |
+
|
71 |
with gr.Row():
|
72 |
model1_input = gr.Textbox(label="Model 1")
|
73 |
with gr.Row():
|
74 |
btn = gr.Button("Prediction for Model 1")
|
75 |
+
classifier = pipeline("text-classification", model=model_id_1)
|
76 |
+
btn.click(fn=predict, inputs=inp_1, outputs=out_2)
|
77 |
|
78 |
|
79 |
|
|
|
81 |
model2_input = gr.Textbox(label="Model 2")
|
82 |
with gr.Row():
|
83 |
btn = gr.Button("Prediction for Model 2")
|
84 |
+
classifier = pipeline("text-classification", model=model_id_2)
|
85 |
+
btn.click(fn=predict, inputs=inp_1, outputs=out_2)
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
app.launch()
|