Spaces:
Sleeping
Sleeping
from transformers import pipeline | |
## Downlaod the PreTrained Model from the Online Repository | |
model = pipeline( | |
"text-classification", | |
model="badmatr11x/roberta-base-emotions-detection-from-text" | |
) | |
def app(): | |
"""This Function takes input from the user | |
and clssify it into different range of emotions. | |
Raises: | |
IOError: Raise an IOError if user input can't convert into the string instance. | |
""" | |
# Get user input | |
try: | |
user_input = str(input("Enter Text Here: ")) | |
except: | |
raise IOError("There is some problem reading text from the console.") | |
# Classify the text using the Huggingface model | |
if user_input: | |
result = model(user_input) | |
else: | |
print("No User Input is Provided.") | |
print(result) | |
if __name__ == "__main__": | |
## Driver Function | |
app() | |