Spaces:
Running
Running
File size: 744 Bytes
d8d4771 4201593 d8d4771 4201593 d8d4771 4201593 d8d4771 4201593 d8d4771 4201593 d8d4771 4201593 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
import gradio as gr
from transformers import pipeline
# Load the BERT-Emotions-Classifier model
classifier = pipeline("text-classification", model="ayoubkirouane/BERT-Emotions-Classifier")
# Define the prediction function for emotion classification
def classify_emotion(text):
result = classifier(text)
return result[0]['label'], result[0]['score']
# Define the Gradio interface
iface = gr.Interface(
fn=classify_emotion, # function that will classify emotion
inputs=gr.Textbox(), # input text box
outputs=[gr.Textbox(), gr.Textbox()], # output emotion label and score
live=True # Enable live mode (optional)
)
# Launch the Gradio interface as an API
iface.launch(share=True)
|