abdulrafishaik commited on
Commit
048b92b
·
verified ·
1 Parent(s): 7a0593d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -15
app.py CHANGED
@@ -1,20 +1,26 @@
1
-
2
  from transformers import pipeline
3
  import gradio as gr
4
 
5
- human_read={"LABEL_0":"Negative",
6
- "LABEL_1":"Positive"}
7
- sentimental=pipeline("text-classification", model="Dmyadav2001/Sentimental-Analysis")
 
 
 
 
8
  def predictive_model(texts):
9
- result=sentimental(texts)
10
- sentiment=human_read[result[0]["label"]]
11
- score=result[0]["score"]
12
- return sentiment, score
 
 
 
 
 
 
 
 
 
13
 
14
- interface=gr.Interface(fn=predictive_model,
15
- inputs="text",
16
- outputs=["text","number"],
17
- title="Sentiment-Analysis-App",
18
- description="Gave your text my machine is going to detect Positive / Negative "
19
- )
20
- interface.launch()
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ # Label mapping
5
+ human_read = {"LABEL_0": "Negative", "LABEL_1": "Positive"}
6
+
7
+ # Load model
8
+ sentimental = pipeline("text-classification", model="Dmyadav2001/Sentimental-Analysis")
9
+
10
+ # Prediction function
11
  def predictive_model(texts):
12
+ result = sentimental(texts)
13
+ sentiment = human_read[result[0]["label"]]
14
+ score = result[0]["score"]
15
+ return sentiment, score
16
+
17
+ # Gradio Interface
18
+ interface = gr.Interface(
19
+ fn=predictive_model,
20
+ inputs="text",
21
+ outputs=["text", "number"],
22
+ title="Sentiment-Analysis-App",
23
+ description="Give your text, and my model will predict whether it's Positive or Negative."
24
+ )
25
 
26
+ interface.launch()