Spaces:
Build error
Build error
| 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() |