File size: 778 Bytes
70b16bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
df3ebd1
8b45fc1
70b16bd
 
 
 
 
 
a179a97
70b16bd
 
 
 
 
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
import numpy as np
import os
import gradio as gr

os.environ["WANDB_DISABLED"] = "true"

from datasets import load_dataset, load_metric
from transformers import (
    AutoConfig,
    # AutoModelForSequenceClassification,
    AutoTokenizer,
    TrainingArguments,
    logging,
pipeline
)


analyzer = pipeline(
    "sentiment-analysis", model="FFZG-cleopatra/M2SA-text-only"
)

def predict_sentiment(x):
    print(analyzer(x))
    return analyzer(x)[0]["label"]


interface = gr.Interface(
    fn=predict_sentiment,
    inputs='text',
    outputs=['text'],
    title='Multilingual Unimodal Sentiment Analysis',
    examples= ["I love tea","I hate coffee"],
    description='Get the positive/neutral/negative sentiment for the given input.'
)

interface.launch(inline = False)