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