thak123 commited on
Commit
18f2d2a
1 Parent(s): b1ce276

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -31,12 +31,11 @@ pipeline
31
 
32
 
33
 
34
- # Question answering pipeline, specifying the checkpoint identifier
35
- # model = AutoModelForSequenceClassification.from_pretrained(
36
- # pretrained_model_name_or_path= "thak123/Cro-Frida",
37
- # num_labels=3,
38
- # )
39
-
40
 
41
  analyzer = pipeline(
42
 
@@ -44,10 +43,7 @@ analyzer = pipeline(
44
 
45
  )
46
  def predict_sentiment(x):
47
- return analyzer(x)
48
-
49
-
50
-
51
 
52
 
53
  interface = gr.Interface(
@@ -55,7 +51,7 @@ interface = gr.Interface(
55
  inputs='text',
56
  outputs=['text'],
57
  title='Croatian Movie reviews Sentiment Analysis',
58
- examples= ["Es mīlu Tevi","Es ienīstu kafiju"],
59
  description='Get the positive/neutral/negative sentiment for the given input.'
60
  )
61
 
 
31
 
32
 
33
 
34
+ label2id = {
35
+ "LABEL_0": "negative",
36
+ "LABEL_1": "neutral",
37
+ "LABEL_2": "positive"
38
+ }
 
39
 
40
  analyzer = pipeline(
41
 
 
43
 
44
  )
45
  def predict_sentiment(x):
46
+ return label2id[analyzer(x)[0]["label"]]
 
 
 
47
 
48
 
49
  interface = gr.Interface(
 
51
  inputs='text',
52
  outputs=['text'],
53
  title='Croatian Movie reviews Sentiment Analysis',
54
+ examples= ["Volim kavu","Ne volim kavu"],
55
  description='Get the positive/neutral/negative sentiment for the given input.'
56
  )
57