Spaces:
Build error
Build error
Added examples to make it easier for the users
Browse files
app.py
CHANGED
|
@@ -14,12 +14,20 @@ def classifier(sentence):
|
|
| 14 |
predicted_label = label_mapping[result[0]['label']]
|
| 15 |
return predicted_label # Should print "negative" or "positive"
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
# Define the Gradio Interface
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=classifier,
|
| 20 |
inputs=gr.Textbox(
|
| 21 |
lines=4,
|
| 22 |
-
placeholder="
|
| 23 |
label="Input Text"
|
| 24 |
),
|
| 25 |
outputs=gr.Textbox(
|
|
@@ -29,6 +37,7 @@ demo = gr.Interface(
|
|
| 29 |
description="Classify the sentiment of the input text as positive or negative.",
|
| 30 |
theme="hugging-face", # Optional, you can experiment with other themes like 'huggingface'
|
| 31 |
allow_flagging="never", # Disable flagging if not needed
|
|
|
|
| 32 |
)
|
| 33 |
|
| 34 |
# Launch the interface
|
|
|
|
| 14 |
predicted_label = label_mapping[result[0]['label']]
|
| 15 |
return predicted_label # Should print "negative" or "positive"
|
| 16 |
|
| 17 |
+
examples = [
|
| 18 |
+
["This movie is amazing!"],
|
| 19 |
+
["I dislike this product."],
|
| 20 |
+
["The food was bland. The texture was fine but the taste was lacking."],
|
| 21 |
+
["The book was enjoyable. The story was good but predictable."],
|
| 22 |
+
["The movie was boring. The plot was dull and unoriginal."]
|
| 23 |
+
]
|
| 24 |
+
|
| 25 |
# Define the Gradio Interface
|
| 26 |
demo = gr.Interface(
|
| 27 |
fn=classifier,
|
| 28 |
inputs=gr.Textbox(
|
| 29 |
lines=4,
|
| 30 |
+
placeholder="Enter a sentence to analyze sentiment (e.g., 'I really liked this product.')",
|
| 31 |
label="Input Text"
|
| 32 |
),
|
| 33 |
outputs=gr.Textbox(
|
|
|
|
| 37 |
description="Classify the sentiment of the input text as positive or negative.",
|
| 38 |
theme="hugging-face", # Optional, you can experiment with other themes like 'huggingface'
|
| 39 |
allow_flagging="never", # Disable flagging if not needed
|
| 40 |
+
examples=examples # Add examples to make it easier for users
|
| 41 |
)
|
| 42 |
|
| 43 |
# Launch the interface
|