Spaces:
Runtime error
Runtime error
yasminesarraj
commited on
Commit
•
b97ac1a
1
Parent(s):
1c2b333
Update app.py
Browse files
app.py
CHANGED
@@ -1,21 +1,14 @@
|
|
1 |
# app.py
|
2 |
-
import
|
3 |
from transformers import pipeline
|
4 |
-
from
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
st.subheader("Enter the text you'd like to analyze.")
|
13 |
-
text = st.text_input('Enter text') #text is stored in this variable
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
else:
|
18 |
-
out = TextBlob(text)
|
19 |
-
out = out.sentiment
|
20 |
-
st.write("Sentiment of Text: ")
|
21 |
-
st.write(out)
|
|
|
1 |
# app.py
|
2 |
+
import gradio as gr
|
3 |
from transformers import pipeline
|
4 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
|
6 |
+
#Defining the classify function which takes text as input and returns the label of the sentiment
|
7 |
+
def classify(text):
|
8 |
+
# Initializing the pipeline for sentiment analysis
|
9 |
+
cls = pipeline('text-classification', model='RJuro/dk_emotion_bert_in_class')
|
10 |
+
# Predicting the sentiment label for the input text
|
11 |
+
return cls(text)[0]['label']
|
|
|
|
|
12 |
|
13 |
+
#Creating the Gradio interface with input textbox and output text
|
14 |
+
gr.Interface(fn=classify, inputs=["textbox"], outputs="text").launch()
|
|
|
|
|
|
|
|
|
|