Spaces:
Runtime error
Runtime error
Commit
·
c0d80b6
1
Parent(s):
7f68476
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
pretrained_sentiment = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
| 6 |
pretrained_ner = "cahya/bert-base-indonesian-NER"
|
|
@@ -31,12 +32,17 @@ def ner(text):
|
|
| 31 |
output = ner_pipeline(text)
|
| 32 |
return {"text": text, "entities": output}
|
| 33 |
|
| 34 |
-
|
| 35 |
-
fn=
|
| 36 |
inputs=gr.Textbox(placeholder="Enter a sentence here..."),
|
| 37 |
-
outputs=
|
| 38 |
-
interpretation=
|
| 39 |
examples=[examples])
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
if __name__ == "__main__":
|
| 42 |
-
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
|
| 3 |
import gradio as gr
|
| 4 |
+
from gradio.mix import Parallel
|
| 5 |
|
| 6 |
pretrained_sentiment = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
| 7 |
pretrained_ner = "cahya/bert-base-indonesian-NER"
|
|
|
|
| 32 |
output = ner_pipeline(text)
|
| 33 |
return {"text": text, "entities": output}
|
| 34 |
|
| 35 |
+
sentiment_demo = gr.Interface(
|
| 36 |
+
fn=sentiment_analysis,
|
| 37 |
inputs=gr.Textbox(placeholder="Enter a sentence here..."),
|
| 38 |
+
outputs="label",
|
| 39 |
+
interpretation="default",
|
| 40 |
examples=[examples])
|
| 41 |
|
| 42 |
+
ner_demo = gr.Interface(ner,
|
| 43 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
| 44 |
+
gr.HighlightedText(),
|
| 45 |
+
examples=examples)
|
| 46 |
+
|
| 47 |
if __name__ == "__main__":
|
| 48 |
+
Parallel(sentiment_demo, ner_demo).launch()
|