Spaces:
Running
Running
File size: 933 Bytes
1539dd6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import gradio as gr
from transformers import pipeline
# Initialize the Hugging Face sentiment-analysis pipeline
nlp = pipeline("sentiment-analysis", model="distilbert-base-uncased-finetuned-sst-2-english")
def sentiment_analysis(text):
result = nlp(text)[0]
return f"label: {result['label']}, with score: {round(result['score'], 4)}"
# Define example inputs
examples = [
['Absolutely love my new lamp from BrightLight Co.! The design is elegant and modern, seamlessly blending into my home decor.'],
['The movie was a great disappointment.'],
['Sarah at SeriouslyNutz has awesome parrot toys. My African Grey loves them all!']
]
iface = gr.Interface(fn=sentiment_analysis,
inputs=gr.inputs.Textbox(lines=7, label="Input Text"), # Set the lines to 7 for a larger text box
outputs="text",
examples=examples) # Add example inputs
iface.launch()
|