Varnikasiva commited on
Commit
5ac8b59
·
verified ·
1 Parent(s): 614443f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -19
app.py CHANGED
@@ -1,19 +1,17 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
- # Load model from your Hugging Face hub
5
- model_id = "Varnikasiva/sentiment-classification-bert-mini"
6
- classifier = pipeline("text-classification", model=model_id)
7
-
8
- # Gradio interface
9
- def predict(text):
10
- result = classifier(text)[0]
11
- return f"Label: {result['label']} (Score: {round(result['score'], 2)})"
12
-
13
- gr.Interface(
14
- fn=predict,
15
- inputs=gr.Textbox(lines=3, placeholder="Type your text here..."),
16
- outputs="text",
17
- title="Sentiment Classification with BERT Mini",
18
- description="This model detects complex emotions like guilt, sarcasm, happiness, etc."
19
- ).launch()
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Force PyTorch backend to avoid loading TensorFlow (and Keras)
5
+ classifier = pipeline("text-classification", model="Varnikasiva/sentiment-classification-bert-mini", framework="pt")
6
+
7
+ def predict(text):
8
+ result = classifier(text)[0]
9
+ return f"Label: {result['label']} (Score: {round(result['score'], 2)})"
10
+
11
+ gr.Interface(
12
+ fn=predict,
13
+ inputs=gr.Textbox(lines=3, placeholder="Type your text here..."),
14
+ outputs="text",
15
+ title="Sentiment Classification with BERT Mini",
16
+ description="Predicts nuanced emotions like sadness, sarcasm, guilt, happiness, and more."
17
+ ).launch()