File size: 599 Bytes
bc1a7a6 19dfad9 bc1a7a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import gradio as gr
from transformers import pipeline
from transformers import AutoTokenizer, AutoModelForSequenceClassification
#Defining the classify function which takes text as input and returns the label of the sentiment
def classify(text):
# Initializing the pipeline for sentiment analysis
cls = pipeline('text-classification', model='Only-Mike/dk_emotion_bert_2')
# Predicting the sentiment label for the input text
return cls(text)[0]['label']
#Creating the Gradio interface with input textbox and output text
gr.Interface(fn=classify, inputs=["textbox"], outputs="text").launch() |