Fabi12 commited on
Commit
0e65767
1 Parent(s): 4756056

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,19 +1,26 @@
1
- import gradio as gr
2
- from transformers import pipeline
3
-
4
 
 
5
  sentiment = pipeline('sentiment-analysis')
6
 
7
-
8
- def get_sentiment(입력):
9
- result = sentiment(입력)
 
 
10
  return f"Label: {result[0]['label']}, Score: {result[0]['score']}"
11
 
12
  # Create a Gradio interface
13
  interface = gr.Interface(
14
  fn=get_sentiment, # Function to call
15
- inputs="text", # Input type (text)
16
- outputs="text" # Output type (text)
 
 
 
 
 
17
  )
18
 
19
  # Launch the Gradio interface
 
1
+ import gradio as gr
2
+ from transformers import pipeline
 
3
 
4
+ # Initialize the sentiment analysis pipeline
5
  sentiment = pipeline('sentiment-analysis')
6
 
7
+ # Define the function to perform sentiment analysis
8
+ def get_sentiment(input_text):
9
+ # Perform sentiment analysis on the input text
10
+ result = sentiment(input_text)
11
+ # Return only the label and score
12
  return f"Label: {result[0]['label']}, Score: {result[0]['score']}"
13
 
14
  # Create a Gradio interface
15
  interface = gr.Interface(
16
  fn=get_sentiment, # Function to call
17
+ inputs=gr.Textbox(lines=3, label="입력"), # Input text area with label in Korean
18
+ outputs=gr.Textbox(label="output"), # Output text area with label in Korean
19
+ title="Sentiment Analysis", # Title of the interface
20
+ buttons=[
21
+ {"text": "글리어", "click": lambda: None}, # Clear button
22
+ {"text": "체출하기", "click": get_sentiment} # Submit button
23
+ ]
24
  )
25
 
26
  # Launch the Gradio interface