Upload 2 files
Browse files- app.py +19 -0
- requirements.txt +6 -0
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
clf = pipeline("text-classification", model="your-username/bert-base-uncased-yelp")
|
| 5 |
+
|
| 6 |
+
def predict(text):
|
| 7 |
+
pred = clf(text)[0]
|
| 8 |
+
return f"Label: {pred['label']} (score={pred['score']:.2f})"
|
| 9 |
+
|
| 10 |
+
demo = gr.Interface(
|
| 11 |
+
fn=predict,
|
| 12 |
+
inputs=gr.Textbox(lines=4, placeholder="Paste a customer review here..."),
|
| 13 |
+
outputs="text",
|
| 14 |
+
title="Sentiment Analysis Demo",
|
| 15 |
+
description="Fine‑tuned BERT‑base model on Yelp Polarity dataset"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
if __name__ == "__main__":
|
| 19 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio>=4.0
|
| 2 |
+
transformers>=4.40
|
| 3 |
+
torch>=2.0
|
| 4 |
+
datasets
|
| 5 |
+
evaluate
|
| 6 |
+
accelerate
|