Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
pipe = pipeline("text-classification", model="lewtun/xlm-roberta-base-finetuned-marc
|
5 |
|
6 |
def predict(text):
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
fn=predict,
|
13 |
title="Review analysis",
|
14 |
description="Enter some review text about an Amazon product and check what the model predicts for it's star rating.",
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
pipe = pipeline("text-classification", model="lewtun/xlm-roberta-base-finetuned-marc")
|
5 |
|
6 |
def predict(text):
|
7 |
+
label2emoji = {"terrible": "π©", "poor": "πΎ", "ok": "π±", "good": "πΊ", "great": "π»"}
|
8 |
+
preds = pipe(text)[0]
|
9 |
+
return label2emoji[preds["label"]], round(preds["score"], 5)
|
10 |
|
11 |
+
gradio_ui = gr.Interface(
|
12 |
fn=predict,
|
13 |
title="Review analysis",
|
14 |
description="Enter some review text about an Amazon product and check what the model predicts for it's star rating.",
|