better interface
Browse files
app.py
CHANGED
@@ -7,18 +7,19 @@ classifier = pipeline("text-classification", model="bhadresh-savani/distilbert-b
|
|
7 |
def classify_emotion(text):
|
8 |
# Make predictions using the Hugging Face pipeline
|
9 |
predictions = classifier(text)
|
|
|
10 |
return {item["label"]: item["score"] for item in predictions}
|
11 |
|
12 |
# Create a custom Gradio interface with title, description, and examples
|
13 |
gr.Interface(
|
14 |
fn=classify_emotion,
|
15 |
inputs=gr.Textbox(
|
16 |
-
placeholder="Enter text to analyze...",
|
17 |
label="Input Text",
|
18 |
lines=4
|
19 |
),
|
20 |
-
outputs=gr.
|
21 |
-
title="Emotion Detection with DistilBERT",
|
22 |
description="This app uses the DistilBERT model fine-tuned for emotion detection. Enter a piece of text to analyze its emotional content!",
|
23 |
examples=[
|
24 |
"I am so happy to see you!",
|
|
|
7 |
def classify_emotion(text):
|
8 |
# Make predictions using the Hugging Face pipeline
|
9 |
predictions = classifier(text)
|
10 |
+
# Convert predictions to a dictionary for gr.Label output
|
11 |
return {item["label"]: item["score"] for item in predictions}
|
12 |
|
13 |
# Create a custom Gradio interface with title, description, and examples
|
14 |
gr.Interface(
|
15 |
fn=classify_emotion,
|
16 |
inputs=gr.Textbox(
|
17 |
+
placeholder="Enter text to analyze...",
|
18 |
label="Input Text",
|
19 |
lines=4
|
20 |
),
|
21 |
+
outputs=gr.Label(label="Emotion Probabilities"), # Use gr.Label for a cleaner interface
|
22 |
+
title="CMACHINES | Emotion Detection with DistilBERT",
|
23 |
description="This app uses the DistilBERT model fine-tuned for emotion detection. Enter a piece of text to analyze its emotional content!",
|
24 |
examples=[
|
25 |
"I am so happy to see you!",
|