Only-Mike commited on
Commit
bc1a7a6
1 Parent(s): c60e498

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -0
app.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
4
+
5
+ #Defining the classify function which takes text as input and returns the label of the sentiment
6
+ def classify(text):
7
+ # Initializing the pipeline for sentiment analysis
8
+ cls = pipeline('text-classification', model='RJuro/dk_emotion_bert_in_class')
9
+ # Predicting the sentiment label for the input text
10
+ return cls(text)[0]['label']
11
+
12
+ #Creating the Gradio interface with input textbox and output text
13
+ gr.Interface(fn=classify, inputs=["textbox"], outputs="text").launch()