Spaces:
Sleeping
Sleeping
Fix app
Browse files
app.py
CHANGED
@@ -4,12 +4,16 @@ from transformers import pipeline
|
|
4 |
class UI:
|
5 |
def __init__(self):
|
6 |
self.model = pipeline("sentiment-analysis", model="lyrisha/bert-finetuned-imdb-sentiment")
|
|
|
|
|
|
|
|
|
7 |
|
8 |
def launch(self):
|
9 |
demo = gr.Interface(
|
10 |
-
fn=self.
|
11 |
inputs="textbox",
|
12 |
-
outputs=
|
13 |
title="Check the mood of the sentence",
|
14 |
description="The model was trained on 'imdb' dataset to classify sentences as 'positive' or 'negative' attitude.",
|
15 |
examples=[["Great news! My reality check just bounced."],
|
|
|
4 |
class UI:
|
5 |
def __init__(self):
|
6 |
self.model = pipeline("sentiment-analysis", model="lyrisha/bert-finetuned-imdb-sentiment")
|
7 |
+
|
8 |
+
def predict(text):
|
9 |
+
predictions = self.model(text)
|
10 |
+
return {p["label"]: p["score"] for p in predictions}
|
11 |
|
12 |
def launch(self):
|
13 |
demo = gr.Interface(
|
14 |
+
fn=self.predict,
|
15 |
inputs="textbox",
|
16 |
+
outputs=gr.Label(num_top_classes=2),
|
17 |
title="Check the mood of the sentence",
|
18 |
description="The model was trained on 'imdb' dataset to classify sentences as 'positive' or 'negative' attitude.",
|
19 |
examples=[["Great news! My reality check just bounced."],
|