Sourbh510 commited on
Commit
aa2e308
·
verified ·
1 Parent(s): 586c564

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load model
5
+ classifier = pipeline("sentiment-analysis", model="textattack/bert-base-uncased-imdb")
6
+
7
+ def predict(text):
8
+ result = classifier(text)[0]
9
+ return f"Label: {result['label']}, Confidence: {round(result['score'], 4)}"
10
+
11
+ interface = gr.Interface(
12
+ fn=predict,
13
+ inputs=gr.Textbox(lines=5, placeholder="Enter movie review..."),
14
+ outputs="text",
15
+ title="IMDb Sentiment Analysis using BERT",
16
+ description="Enter a movie review to classify sentiment."
17
+ )
18
+
19
+ interface.launch()