File size: 1,104 Bytes
990dc13
 
 
 
 
 
 
 
 
2cdf71f
990dc13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18f2d2a
 
 
 
 
990dc13
 
 
2cdf71f
990dc13
 
 
18f2d2a
990dc13
 
 
 
 
b1ce276
2cdf71f
18f2d2a
990dc13
 
 
 
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
)




# model_name = 


# tokenizer = AutoTokenizer.from_pretrained(model_name)

# config = AutoConfig.from_pretrained(model_name)

# pipe = pipeline("text-classification")

# pipe("This restaurant is awesome")




label2id =  {
    "LABEL_0": "negative",
    "LABEL_1": "neutral",
    "LABEL_2": "positive"
  }

analyzer = pipeline(

    "sentiment-analysis", model="thak123/Cro-Frida", tokenizer="EMBEDDIA/crosloengual-bert"

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


interface = gr.Interface(
    fn=predict_sentiment,
    inputs='text',
    outputs=['text'],
    title='Croatian Movie reviews Sentiment Analysis',
    examples= ["Volim kavu","Ne volim kavu"],
    description='Get the positive/neutral/negative sentiment for the given input.'
)

interface.launch(inline = False)