Commit
·
dcf4bbc
1
Parent(s):
f6364ae
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def predict_sentiment(text):
|
4 |
+
model_output = gr.load("models/quocviethere/roberta-sentiment-model").process(text)
|
5 |
+
# Convert the model output to a more readable format
|
6 |
+
if model_output[0] > model_output[1]: # Assuming index 0 is for negative sentiment
|
7 |
+
return "Negative Review", model_output[0]
|
8 |
+
else:
|
9 |
+
return "Positive Review", model_output[1]
|
10 |
+
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=predict_sentiment,
|
13 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Type your review here"),
|
14 |
+
outputs=[
|
15 |
+
gr.outputs.Label(num_top_classes=2, label="Sentiment Analysis")
|
16 |
+
]
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch()
|
20 |
+
|