Spaces:
Sleeping
Sleeping
Purvesh Patel
commited on
Commit
•
f0c227a
1
Parent(s):
40da69e
rename the application.py -> app.py
Browse files
app.py
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
|
3 |
+
## Downlaod the PreTrained Model from the Online Repository
|
4 |
+
model = pipeline(
|
5 |
+
"text-classification",
|
6 |
+
model="badmatr11x/roberta-base-emotions-detection-from-text"
|
7 |
+
)
|
8 |
+
|
9 |
+
|
10 |
+
def app():
|
11 |
+
"""This Function takes input from the user
|
12 |
+
and clssify it into different range of emotions.
|
13 |
+
|
14 |
+
Raises:
|
15 |
+
IOError: Raise an IOError if user input can't convert into the string instance.
|
16 |
+
"""
|
17 |
+
# Get user input
|
18 |
+
try:
|
19 |
+
user_input = str(input("Enter Text Here: "))
|
20 |
+
except:
|
21 |
+
raise IOError("There is some problem reading text from the console.")
|
22 |
+
|
23 |
+
# Classify the text using the Huggingface model
|
24 |
+
if user_input:
|
25 |
+
result = model(user_input)
|
26 |
+
else:
|
27 |
+
print("No User Input is Provided.")
|
28 |
+
|
29 |
+
print(result)
|
30 |
+
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
## Driver Function
|
34 |
+
app()
|