Spaces:
Runtime error
Runtime error
Commit
·
ef26fd6
1
Parent(s):
b23854e
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,10 +2,10 @@ from transformers import pipeline
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
-
pretrained_name = "
|
| 6 |
|
| 7 |
-
|
| 8 |
-
"
|
| 9 |
model=pretrained_name,
|
| 10 |
tokenizer=pretrained_name
|
| 11 |
)
|
|
@@ -14,14 +14,17 @@ examples = [
|
|
| 14 |
"Ada apa dengan Jokowi di istana negara?",
|
| 15 |
]
|
| 16 |
|
| 17 |
-
def
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
-
demo = gr.Interface(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if __name__ == "__main__":
|
| 27 |
demo.launch()
|
|
|
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
pretrained_name = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
| 6 |
|
| 7 |
+
sentiment = pipeline(
|
| 8 |
+
"sentiment-analysis",
|
| 9 |
model=pretrained_name,
|
| 10 |
tokenizer=pretrained_name
|
| 11 |
)
|
|
|
|
| 14 |
"Ada apa dengan Jokowi di istana negara?",
|
| 15 |
]
|
| 16 |
|
| 17 |
+
def sentiment_analysis(text):
|
| 18 |
+
scores = sid.polarity_scores(text)
|
| 19 |
+
del scores["compound"]
|
| 20 |
+
return scores
|
| 21 |
|
| 22 |
+
demo = gr.Interface(
|
| 23 |
+
fn=sentiment_analysis,
|
| 24 |
+
inputs=gr.Textbox(placeholder="Enter a sentence here..."),
|
| 25 |
+
outputs="label",
|
| 26 |
+
interpretation="default",
|
| 27 |
+
examples=[examples])
|
| 28 |
|
| 29 |
if __name__ == "__main__":
|
| 30 |
demo.launch()
|