Spaces:
Build error
Build error
Updated application file
Browse files
app.py
CHANGED
|
@@ -1,11 +1,39 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
from transformers import pipeline
|
|
|
|
| 3 |
|
| 4 |
model_path="matiss/Latvian-Twitter-Sentiment-Analysis"
|
| 5 |
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
| 6 |
|
| 7 |
def classify(text):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
demo
|
| 11 |
-
demo.launch()
|
|
|
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
|
| 4 |
model_path="matiss/Latvian-Twitter-Sentiment-Analysis"
|
| 5 |
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
| 6 |
|
| 7 |
def classify(text):
|
| 8 |
+
output = sentiment_task(text)
|
| 9 |
+
return output[0]['label'], output[0]['score']
|
| 10 |
+
|
| 11 |
+
#demo = gr.Interface(fn=classify, inputs="text", outputs="text")
|
| 12 |
+
|
| 13 |
+
with gr.Blocks() as demo:
|
| 14 |
+
with gr.Row():
|
| 15 |
+
with gr.Column():
|
| 16 |
+
textbox = gr.Textbox(label="Input text:", placeholder="Man garšo pankūkas ar kotletēm", lines=5)
|
| 17 |
+
greet_btn = gr.Button("Classify")
|
| 18 |
+
with gr.Column():
|
| 19 |
+
outbox = gr.Textbox(label="Prediction:", placeholder="positive")
|
| 20 |
+
runbox = gr.Textbox(label="Score")
|
| 21 |
+
|
| 22 |
+
greet_btn.click(
|
| 23 |
+
fn=classify,
|
| 24 |
+
inputs=textbox,
|
| 25 |
+
outputs=[outbox, runbox]
|
| 26 |
+
)
|
| 27 |
+
examples = gr.Examples(
|
| 28 |
+
examples=[
|
| 29 |
+
["Lietus šodien līst kā pa Jāņiem."],
|
| 30 |
+
["Es neciešu pirmdienas"],
|
| 31 |
+
["Pusdienās Tev jāēd brokolis, steiks, biezpiensieriņš un jāuzdzer Dlight."],
|
| 32 |
+
["Nesaprotu vairs kas te tagad notiek"],
|
| 33 |
+
["Man garšo pankūkas ar kotletēm"],
|
| 34 |
+
],
|
| 35 |
+
inputs=[textbox],
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
|
| 39 |
+
demo.launch(server_name='local-alien.s.aist.go.jp', share=True, debug=True)
|
|
|