thak123 commited on
Commit
70b16bd
1 Parent(s): 7bad73e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import os
3
+ import gradio as gr
4
+
5
+ os.environ["WANDB_DISABLED"] = "true"
6
+
7
+ from datasets import load_dataset, load_metric
8
+ from transformers import (
9
+ AutoConfig,
10
+ # AutoModelForSequenceClassification,
11
+ AutoTokenizer,
12
+ TrainingArguments,
13
+ logging,
14
+ pipeline
15
+ )
16
+
17
+
18
+ analyzer = pipeline(
19
+ "sentiment-analysis", model="FFZG-cleopatra/M2SA-text-only"
20
+ )
21
+
22
+ def predict_sentiment(x):
23
+ print(label2id[analyzer(x))
24
+ return label2id[analyzer(x)[0]["label"]]
25
+
26
+
27
+ interface = gr.Interface(
28
+ fn=predict_sentiment,
29
+ inputs='text',
30
+ outputs=['text'],
31
+ title='Multilingual-Multimodal-Sentiment-Analysis',
32
+ examples= ["I love tea","I hate coffee"],
33
+ description='Get the positive/neutral/negative sentiment for the given input.'
34
+ )
35
+
36
+ interface.launch(inline = False)