aromal003 commited on
Commit
778a660
·
verified ·
1 Parent(s): 624dc69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -1,16 +1,21 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
 
4
  sentiment_pipeline = pipeline("sentiment-analysis")
 
 
5
  def get_sentiment(input_text):
6
- result = get_sentiment(input_text)
7
- return result[0].['label']
8
 
9
- #Lauch the we ui
10
- iface = gt.Interface(
11
- inputs = "text",
12
- outputs = "text",
13
- title = "My first AI app",
14
- description = "Enter some text and I will tell you whether it is positive or negative"
 
15
  )
16
- iface.launch()
 
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ # Load the sentiment analysis pipeline
5
  sentiment_pipeline = pipeline("sentiment-analysis")
6
+
7
+ # Corrected function
8
  def get_sentiment(input_text):
9
+ result = sentiment_pipeline(input_text) # Use the pipeline, not the function itself
10
+ return result[0]['label'] # Access the label correctly
11
 
12
+ # Launch the web UI
13
+ iface = gr.Interface(
14
+ fn=get_sentiment, # Pass the function to Gradio
15
+ inputs="text",
16
+ outputs="text",
17
+ title="My First AI App",
18
+ description="Enter some text and I will tell you whether it is Positive or Negative."
19
  )
20
+
21
+ iface.launch()