| import gradio as gr | |
| from transformers import pipeline | |
| clf = pipeline("text-classification", model="your-username/bert-base-uncased-yelp") | |
| def predict(text): | |
| pred = clf(text)[0] | |
| return f"Label: {pred['label']} (score={pred['score']:.2f})" | |
| demo = gr.Interface( | |
| fn=predict, | |
| inputs=gr.Textbox(lines=4, placeholder="Paste a customer review here..."), | |
| outputs="text", | |
| title="Sentiment Analysis Demo", | |
| description="Fine‑tuned BERT‑base model on Yelp Polarity dataset" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |