seonoh12 commited on
Commit
0fce7c2
·
verified ·
1 Parent(s): 3444654

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -16
app.py CHANGED
@@ -1,20 +1,11 @@
1
  import gradio as gr
2
- import transformers
3
 
4
- # Load the pre-trained sentiment analysis model
5
- model = transformers.pipeline("sentiment-analysis")
6
 
7
- # Define the Gradio interface
8
- def sentiment_analysis(text):
9
- result = model(text)[0]
10
- label = result["label"]
11
- score = result["score"]
12
- return f"{label} with confidence score {score:.2f}"
13
 
14
- iface = gr.Interface(fn=sentiment_analysis,
15
- inputs=gr.inputs.Textbox(lines=5, label="Input text"),
16
- outputs="text",
17
- title="Sentiment Analysis")
18
-
19
- # Launch the Gradio interface
20
- iface.launch()
 
1
  import gradio as gr
 
2
 
3
+ from transformers import pipeline
 
4
 
5
+ sentiment= pipeline("sentiment-analysis")
 
 
 
 
 
6
 
7
+ def get_sentiment(input_text):
8
+ return sentiment(input_text)
9
+
10
+ iface= gr.Interface(fn= get_sentiment, inputs="text", outputs= ['text'], title='Sentiment- Analysis')
11
+ iface.launch(inline=False)