Asmatullah-AI-Engineer commited on
Commit
0d97207
·
verified ·
1 Parent(s): 21f66e2

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ classifier = pipeline(
5
+ "text-classification",
6
+ model="Asmatullah-AI-Engineer/distilbert-imdb-sentiment"
7
+ )
8
+
9
+ def predict(text):
10
+ result = classifier(text)[0]
11
+ label = result["label"]
12
+ score = result["score"]
13
+ return f"{label} (confidence: {score:.3f})"
14
+
15
+ demo = gr.Interface(
16
+ fn=predict,
17
+ inputs=gr.Textbox(placeholder="Enter a movie review..."),
18
+ outputs=gr.Textbox(label="Sentiment"),
19
+ title="Movie Sentiment Classifier",
20
+ description="Fine-tuned DistilBERT on IMDb reviews"
21
+ )
22
+
23
+ demo.launch()